diff options
author | Brian Paul <[email protected]> | 2005-01-09 17:37:50 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-01-09 17:37:50 +0000 |
commit | 92eddb0fd404624ca198f19e4088927701eec7f5 (patch) | |
tree | dd93d51d271e6bd43d09af9e8b0f3a98a640a8d2 /progs/demos/spectex.c | |
parent | 516f9bc6e306fe7820649ead125d557b46ca8419 (diff) |
better animate rate (Marcelo Magallon)
Diffstat (limited to 'progs/demos/spectex.c')
-rw-r--r-- | progs/demos/spectex.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/progs/demos/spectex.c b/progs/demos/spectex.c index 9364245995d..cfa7f74a21a 100644 --- a/progs/demos/spectex.c +++ b/progs/demos/spectex.c @@ -25,8 +25,8 @@ static GLUquadricObj *Quadric; static GLuint Sphere; static GLfloat LightPos[4] = {10.0, 10.0, 10.0, 1.0}; -static GLfloat Delta = 1.0; -static GLint Mode = 0; +static GLfloat Delta = 20.0; +static GLint Mode = 4; /*static GLfloat Blue[4] = {0.0, 0.0, 1.0, 1.0};*/ /*static GLfloat Gray[4] = {0.5, 0.5, 0.5, 1.0};*/ @@ -34,14 +34,18 @@ static GLfloat Black[4] = {0.0, 0.0, 0.0, 1.0}; static GLfloat White[4] = {1.0, 1.0, 1.0, 1.0}; - -static void Idle( void ) +static void +Idle(void) { - LightPos[0] += Delta; - if (LightPos[0]>15.0) - Delta = -1.0; - else if (LightPos[0]<-15.0) - Delta = 1.0; + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + LightPos[0] += Delta * dt; + if (LightPos[0]>15.0 || LightPos[0]<-15.0) + Delta = -Delta; glutPostRedisplay(); } |