Commit 84ee17d9 authored by Siarhei Siamashka's avatar Siarhei Siamashka
Browse files

test: use spacebar as a slow motion hotkey for gles-rgb-cycle-demo



Whenever something goes wrong in high fps mode, it may be interesting
to slow down the demo to check whether the actual background color
matches the expected color (shown in the window title).
Signed-off-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
parent 67d2e229
...@@ -97,6 +97,7 @@ static const EGLint context_attribute_list[] = { ...@@ -97,6 +97,7 @@ static const EGLint context_attribute_list[] = {
EGLDisplay egl_display; EGLDisplay egl_display;
EGLSurface egl_surface; EGLSurface egl_surface;
static int slow_motion = 0;
static int msleep_time = 1000; static int msleep_time = 1000;
static int fullscreen_state = 1; static int fullscreen_state = 1;
static int framecount = 0; static int framecount = 0;
...@@ -128,6 +129,9 @@ Redraw(int width, int height) ...@@ -128,6 +129,9 @@ Redraw(int width, int height)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(egl_display, egl_surface); eglSwapBuffers(egl_display, egl_surface);
if (slow_motion)
usleep(1000 * 1000);
else
usleep(msleep_time * 1000); usleep(msleep_time * 1000);
} }
...@@ -264,7 +268,8 @@ main(int argc, char *argv[]) ...@@ -264,7 +268,8 @@ main(int argc, char *argv[])
printf("between red, green and blue (starting with red).\n"); printf("between red, green and blue (starting with red).\n");
printf("The animation speed is %d milliseconds per frame.\n", msleep_time); printf("The animation speed is %d milliseconds per frame.\n", msleep_time);
printf("\n"); printf("\n");
printf("Press 'f' to toggle between fullscreen and windowed mode.\n\n"); printf("Press 'f' to toggle between fullscreen and windowed mode.\n");
printf("Press ' ' to toggle between normal speed and slow motion.\n\n");
#ifdef USE_X #ifdef USE_X
set_fullscreen_state(fullscreen_state); set_fullscreen_state(fullscreen_state);
...@@ -281,6 +286,8 @@ main(int argc, char *argv[]) ...@@ -281,6 +286,8 @@ main(int argc, char *argv[])
break; break;
if (xev.type == KeyPress && xev.xkey.keycode == 41) if (xev.type == KeyPress && xev.xkey.keycode == 41)
set_fullscreen_state(fullscreen_state ^= 1); set_fullscreen_state(fullscreen_state ^= 1);
if (xev.type == KeyPress && xev.xkey.keycode == 65)
slow_motion ^= 1;
} }
Redraw(width, height); Redraw(width, height);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment