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/sphere.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'progs/samples/sphere.c') diff --git a/progs/samples/sphere.c b/progs/samples/sphere.c index cbe2cb1868..7d0508dee9 100644 --- a/progs/samples/sphere.c +++ b/progs/samples/sphere.c @@ -29,7 +29,7 @@ #include #include #include -#include "../util/readtex.c" +#include "readtex.h" #ifndef PI @@ -820,8 +820,16 @@ void Reshape(int width, int height) void Idle(void) { - xRotation += .75; - yRotation += .375; + static double t0 = -1.; + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = t - t0; + t0 = t; + + xRotation += .75*60.*dt; + yRotation += .375*60.*dt; glutPostRedisplay(); } -- cgit v1.2.3