diff options
Diffstat (limited to 'tests/common/test_gl.c')
| -rw-r--r-- | tests/common/test_gl.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/common/test_gl.c b/tests/common/test_gl.c index 1bb5bec..0b91bff 100644 --- a/tests/common/test_gl.c +++ b/tests/common/test_gl.c @@ -146,6 +146,25 @@ int main(int argc, char **argv) clear(GL_COLOR_BUFFER_BIT_); REQUIRE((yasl_gl_present(primary) == 0), "swap resized GL surface"); + /* An animation that asks for each next frame gets one REFRESH per frame + * shown, even though GL surfaces also get a REFRESH when a frame is shown. */ + REQUIRE(yasl_surface_request_frame(primary) == 0, "request a frame"); + int frames = 0; + double animation_end = seconds_now() + 1.0; + while (seconds_now() < animation_end) { + yasl_event event = {0}; + int result = yasl_wait_event(&event, 50); + REQUIRE(result >= 0, "wait during animation"); + if (result == 0 || event.type != YASL_EVENT_REFRESH || event.surface != primary) + continue; + frames++; + REQUIRE(yasl_surface_request_frame(primary) == 0, "request the next frame"); + clear(GL_COLOR_BUFFER_BIT_); + REQUIRE(yasl_gl_present(primary) == 0, "present an animation frame"); + } + fprintf(stderr, "%d REFRESH events in 1 s of GL animation\n", frames); + REQUIRE(frames >= 20 && frames <= 75, "one REFRESH per frame shown"); + REQUIRE(yasl_surface_create(&(struct yasl_surface_options){.title="invalid attrs", .width=100, .height=100, .type=YASL_SURFACE_GL, .gl = {.major = -1}}) == NULL && errno == EINVAL, "reject invalid GL context options"); cpu = yasl_surface_create(&(struct yasl_surface_options){.title="CPU surface", .width=100, .height=100}); |
