X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=progs%2Fdemos%2Ftexcyl.c;h=c04d5004e37572f6ee2355ef0b220db2f442765e;hb=a1a6fa2fa18c4982aa8151042df7d04551e47981;hp=61c8d908b06b4b47f1aff081c41aa324f1eb8497;hpb=9ac51f57efe07ed43a1e4224a7f5daddec401b36;p=mesa.git diff --git a/progs/demos/texcyl.c b/progs/demos/texcyl.c index 61c8d908b06..c04d5004e37 100644 --- a/progs/demos/texcyl.c +++ b/progs/demos/texcyl.c @@ -12,9 +12,10 @@ #include #include #include +#include #include -#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(); } } @@ -115,6 +123,10 @@ static void ModeMenu(int entry) { if (entry==ANIMATE) { Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); } else if (entry==POINT_FILTER) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -139,6 +151,13 @@ static void Key( unsigned char key, int x, int y ) (void) x; (void) y; switch (key) { + case ' ': + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; case 27: exit(0); break;