diff options
Diffstat (limited to 'progs/demos/geartrain.c')
-rw-r--r-- | progs/demos/geartrain.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/progs/demos/geartrain.c b/progs/demos/geartrain.c index ec31e743abc..3feb2a0524b 100644 --- a/progs/demos/geartrain.c +++ b/progs/demos/geartrain.c @@ -912,14 +912,18 @@ draw (void) } - - static void idle (void) { int i; + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; for (i = 0; i < number_of_gears; i++) - g[i].angle += g[i].angular_velocity; + g[i].angle += g[i].angular_velocity * dt; glutPostRedisplay(); } |