Add a mode to test flat shading + separate specular.
authorKeith Whitwell <keith@tungstengraphics.com>
Wed, 1 Jun 2005 07:02:23 +0000 (07:02 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Wed, 1 Jun 2005 07:02:23 +0000 (07:02 +0000)
progs/demos/spectex.c

index cfa7f74a21acdee0288f856d088e11b91213ba97..6ab1191579c3be6d41e43329c40e84c8e2a057b7 100644 (file)
@@ -33,6 +33,7 @@ static GLint Mode = 4;
 static GLfloat Black[4] = {0.0, 0.0, 0.0, 1.0};
 static GLfloat White[4] = {1.0, 1.0, 1.0, 1.0};
 
+static GLboolean smooth = 1;
 
 static void
 Idle(void)
@@ -143,9 +144,16 @@ static void Key( unsigned char key, int x, int y )
    (void) x;
    (void) y;
    switch (key) {
-      case 27:
-         exit(0);
-         break;
+   case 27:
+      exit(0);
+      break;
+   case 's':
+      smooth = !smooth;
+      if (smooth)
+         glShadeModel(GL_SMOOTH);
+      else
+         glShadeModel(GL_FLAT);
+      break;
    }
    glutPostRedisplay();
 }
@@ -175,6 +183,8 @@ static void Init( void )
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Black);
 
+   glShadeModel(GL_SMOOTH);
+
    glMaterialfv(GL_FRONT, GL_DIFFUSE, White);
    glMaterialfv(GL_FRONT, GL_SPECULAR, White);
    glMaterialf(GL_FRONT, GL_SHININESS, 20.0);