summaryrefslogtreecommitdiffstats
path: root/progs/demos
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-12-08 17:49:50 +0000
committerBrian Paul <[email protected]>2005-12-08 17:49:50 +0000
commit21b2784ff52cc4e61082e3aa9a8b1714862505b2 (patch)
treec56d8703045bd3b926e174a6c462a6906209dba4 /progs/demos
parent5abc246f8d56b52a7aaaa5458e655456e9e420a8 (diff)
'a' key to toggle animation
Diffstat (limited to 'progs/demos')
-rw-r--r--progs/demos/morph3d.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/progs/demos/morph3d.c b/progs/demos/morph3d.c
index 047d571c705..162a6ff847e 100644
--- a/progs/demos/morph3d.c
+++ b/progs/demos/morph3d.c
@@ -176,6 +176,7 @@ So the angle is:
static int mono=0;
static int smooth=1;
+static int anim=1;
static GLint WindH, WindW;
static GLfloat step=0;
static GLfloat seno;
@@ -660,13 +661,6 @@ static void draw_ico( void )
}
static void draw ( 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;
-
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix();
@@ -688,11 +682,19 @@ static void draw ( void ) {
glutSwapBuffers();
- step += dt;
}
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;
+
+ step += dt;
+
glutPostRedisplay();
}
@@ -718,11 +720,19 @@ static void key( unsigned char k, int x, int y )
case '4': object=4; break;
case '5': object=5; break;
case ' ': mono^=1; break;
- case 13: smooth^=1; break;
+ case 's': smooth^=1; break;
+ case 'a':
+ anim^=1;
+ if (anim)
+ glutIdleFunc( idle_ );
+ else
+ glutIdleFunc(NULL);
+ break;
case 27:
exit(0);
}
pinit();
+ glutPostRedisplay();
}
static void pinit(void)