Detect sinf/cosf/sqrtf presence with CMake (instead of relying on __cpluscplus)
[freeglut] / progs / demos / shapes / shapes.c
index ac0a48c..271ea04 100644 (file)
@@ -14,6 +14,7 @@
       -    <tt>q Q &nbsp;</tt> Quit
       -    <tt>i I &nbsp;</tt> Show info
       -    <tt>p P &nbsp;</tt> Toggle perspective or orthographic projection
+      -    <tt>r R &nbsp;</tt> Toggle fixed or animated rotation around model X-axis
       -    <tt>= + &nbsp;</tt> Increase \a slices
       -    <tt>- _ &nbsp;</tt> Decreate \a slices
       -    <tt>, < &nbsp;</tt> 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
@@ -87,8 +89,6 @@ static void drawSolidIcosahedron(void)         { glutSolidIcosahedron ();
 static void drawWireIcosahedron(void)          { glutWireIcosahedron ();                         }
 static void drawSolidSierpinskiSponge(void)    { glutSolidSierpinskiSponge (depth, offset, orad);}  /* orad doubles as size input */
 static void drawWireSierpinskiSponge(void)     { glutWireSierpinskiSponge (depth, offset, orad); }  /* orad doubles as size input */
-static void drawSolidTeapot(void)              { glutSolidTeapot(orad);                          }  /* orad doubles as size input */
-static void drawWireTeapot(void)               { glutWireTeapot(orad);                           }  /* orad doubles as size input */
 static void drawSolidTorus(void)               { glutSolidTorus(irad,orad,slices,stacks);        }
 static void drawWireTorus(void)                { glutWireTorus (irad,orad,slices,stacks);        }
 static void drawSolidSphere(void)              { glutSolidSphere(orad,slices,stacks);            }  /* orad doubles as size input */
@@ -97,6 +97,24 @@ static void drawSolidCone(void)                { glutSolidCone(orad,orad,slices,
 static void drawWireCone(void)                 { glutWireCone(orad,orad,slices,stacks);          }  /* orad doubles as size input */
 static void drawSolidCylinder(void)            { glutSolidCylinder(orad,orad,slices,stacks);     }  /* orad doubles as size input */
 static void drawWireCylinder(void)             { glutWireCylinder(orad,orad,slices,stacks);      }  /* orad doubles as size input */
+static void drawSolidTeapot(void)
+{
+    /* per Glut manpage, it should be noted that the teapot is rendered
+     * with clockwise winding for front facing polygons...
+     */
+    glFrontFace(GL_CW);
+    glutSolidTeapot(orad);  /* orad doubles as size input */
+    glFrontFace(GL_CCW);
+}
+static void drawWireTeapot(void)
+{
+    /* per Glut manpage, it should be noted that the teapot is rendered
+     * with clockwise winding for front facing polygons...
+     */
+    glFrontFace(GL_CW);
+    glutWireTeapot(orad);  /* orad doubles as size input */
+    glFrontFace(GL_CCW);
+}
 
 #define RADIUS    1.0f
 
@@ -236,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();
@@ -254,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();
@@ -317,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;
     }