summaryrefslogtreecommitdiffstats
path: root/progs/samples/stretch.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-01-08 23:52:01 +0000
committerBrian Paul <[email protected]>2005-01-08 23:52:01 +0000
commitc1065ee977f70042e54a930a6cd3af819d4a9806 (patch)
tree45053d22bc302bde8c627e9e8d2cc174a17c844a /progs/samples/stretch.c
parent0261042bebe4c17afd3b581fac0ab5274dac3740 (diff)
compute reasonable animate rate (Marcelo Magallon)
Diffstat (limited to 'progs/samples/stretch.c')
-rw-r--r--progs/samples/stretch.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/progs/samples/stretch.c b/progs/samples/stretch.c
index 9efa8e187e3..1fd015d794a 100644
--- a/progs/samples/stretch.c
+++ b/progs/samples/stretch.c
@@ -265,6 +265,17 @@ void Mouse(int button, int state, int mouseX, int mouseY)
void Animate(void)
{
+ static double t0 = -1.;
+ double t, dt;
+ t = glutGet(GLUT_ELAPSED_TIME) / 1000.;
+ if (t0 < 0.)
+ t0 = t;
+ dt = t - t0;
+
+ if (dt < 1./60.)
+ return;
+
+ t0 = t;
switch (op) {
case OP_STRETCH:
@@ -307,6 +318,10 @@ static GLenum Args(int argc, char **argv)
return GL_TRUE;
}
+#if !defined(GLUTCALLBACK)
+#define GLUTCALLBACK
+#endif
+
void GLUTCALLBACK glut_post_redisplay_p(void)
{
glutPostRedisplay();