diff options
author | Erik Faye-Lund <erik.faye-lund@collabora.com> | 2020-04-17 00:09:11 +0200 |
---|---|---|
committer | Erik Faye-Lund <erik.faye-lund@collabora.com> | 2020-04-20 11:50:56 +0200 |
commit | a394b83f5292be58cd538322521457b8bf05d84a (patch) | |
tree | 5fb6bd3c8bd83cca41d6fedad3664958948ce1e9 | |
parent | 12a2b4cca99891ea2e09506301e7eba0b96d1584 (diff) |
wglgears: implement animate-state
This allows the animation to be paused and resumed, just like with
glxgears.
Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r-- | src/wgl/wglgears.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/wgl/wglgears.c b/src/wgl/wglgears.c index fd506dfd..973930e6 100644 --- a/src/wgl/wglgears.c +++ b/src/wgl/wglgears.c @@ -67,6 +67,7 @@ static GLfloat angle = 0.0; static GLint samples = 0; static GLboolean use_srgb = GL_FALSE; +static GLboolean animate = GL_TRUE; static @@ -335,6 +336,8 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) view_rotx -= 5.0; else if (wParam == VK_ESCAPE) PostQuitMessage(0); + else if (wParam == 'A') + animate = !animate; return 0; #if WINVER >= 0x0605 case WM_NCCREATE: @@ -501,10 +504,12 @@ draw_frame() dt = t - tRot0; tRot0 = t; - /* advance rotation for next frame */ - angle += 70.0 * dt; /* 70 degrees per second */ - if (angle > 3600.0) - angle -= 3600.0; + if (animate) { + /* advance rotation for next frame */ + angle += 70.0 * dt; /* 70 degrees per second */ + if (angle > 3600.0) + angle -= 3600.0; + } draw(); SwapBuffers(hDC); |