From b38f7bf82ab934dce11fbfdd21ca32da72f73c6a Mon Sep 17 00:00:00 2001 From: Diederick Niehorster Date: Sun, 22 Apr 2012 16:39:47 +0000 Subject: [PATCH] added 'r' toggle to shapes demo to also animate rotation around object x-axis, to get a better view of the model git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1264 7f0cb862-5218-0410-a997-914c9d46530a --- progs/demos/shapes/shapes.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/progs/demos/shapes/shapes.c b/progs/demos/shapes/shapes.c index 3b1e98e..271ea04 100644 --- a/progs/demos/shapes/shapes.c +++ b/progs/demos/shapes/shapes.c @@ -14,6 +14,7 @@ - q Q   Quit - i I   Show info - p P   Toggle perspective or orthographic projection + - r R   Toggle fixed or animated rotation around model X-axis - = +   Increase \a slices - - _   Decreate \a slices - , <   Decreate \a stacks @@ -67,6 +68,7 @@ static double offset[ 3 ] = { 0, 0, 0 }; static GLboolean show_info = GL_TRUE; static float ar; static GLboolean persProject = GL_TRUE; +static GLboolean animateXRot = GL_FALSE; /* * These one-liners draw particular objects, fetching appropriate @@ -252,6 +254,7 @@ static void display(void) { const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; const double a = t*90.0; + const double b = (animateXRot?t:1)*60.0; glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -270,14 +273,14 @@ static void display(void) glPushMatrix(); glTranslated(0,1.2,-6); - glRotated(60,1,0,0); + glRotated(b,1,0,0); glRotated(a,0,0,1); table [function_index].solid (); glPopMatrix(); glPushMatrix(); glTranslated(0,-1.2,-6); - glRotated(60,1,0,0); + glRotated(b,1,0,0); glRotated(a,0,0,1); table [function_index].wire (); glPopMatrix(); @@ -333,6 +336,9 @@ key(unsigned char key, int x, int y) case 'P': case 'p': persProject=!persProject; break; + case 'R': + case 'r': animateXRot=!animateXRot; break; + default: break; } -- 1.7.10.4