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/texcyl.c | |
parent | 516f9bc6e306fe7820649ead125d557b46ca8419 (diff) |
better animate rate (Marcelo Magallon)
Diffstat (limited to 'progs/demos/texcyl.c')
-rw-r--r-- | progs/demos/texcyl.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/progs/demos/texcyl.c b/progs/demos/texcyl.c index 52f7da0af20..c04d5004e37 100644 --- a/progs/demos/texcyl.c +++ b/progs/demos/texcyl.c @@ -12,9 +12,10 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <string.h> #include <GL/glut.h> -#include "readtex.c" /* I know, this is a hack. */ +#include "readtex.h" #define TEXTURE_FILE "../images/reflect.rgb" @@ -30,7 +31,7 @@ static GLuint CylinderObj = 0; static GLboolean Animate = GL_TRUE; static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; -static GLfloat DXrot = 1.0, DYrot = 2.5; +static GLfloat DXrot = 50.0, DYrot = 125.0; /* performance info */ static GLint T0 = 0; @@ -39,9 +40,16 @@ static GLint Frames = 0; static void Idle( void ) { + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + if (Animate) { - Xrot += DXrot; - Yrot += DYrot; + Xrot += DXrot * dt; + Yrot += DYrot * dt; glutPostRedisplay(); } } |