From c1065ee977f70042e54a930a6cd3af819d4a9806 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 8 Jan 2005 23:52:01 +0000 Subject: compute reasonable animate rate (Marcelo Magallon) --- progs/samples/wave.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'progs/samples/wave.c') diff --git a/progs/samples/wave.c b/progs/samples/wave.c index 7ded49bedc..d3c4687459 100644 --- a/progs/samples/wave.c +++ b/progs/samples/wave.c @@ -87,9 +87,26 @@ GLubyte contourTexture2[] = { 255, 127, 127, 127, }; +#if !defined(GLUTCALLBACK) +#define GLUTCALLBACK +#endif + + void GLUTCALLBACK glut_post_redisplay_p(void) { - glutPostRedisplay(); + static double t0 = -1.; + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = t - t0; + + if (dt < 1./30.) + return; + + t0 = t; + + glutPostRedisplay(); } static void Animate(void) -- cgit v1.2.3