Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
[mesa.git] / progs / trivial / tri-cull.c
index af26cb0b2beaa43e4091d4d59e5b4642855850a2..c71ad9a0315ac97baae6768a572174030be00276 100644 (file)
@@ -29,6 +29,7 @@
 
 static GLenum doubleBuffer;
 static GLint cullmode = 0;
+static GLenum front = GL_CCW; /* GL default */
 
 static void cull(void)
 {
@@ -59,6 +60,7 @@ static void Init(void)
    fprintf(stderr, "GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
    fprintf(stderr, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
    fprintf(stderr, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
+   fflush(stderr);
    glClearColor(0.0, 0.0, 1.0, 0.0);
    cull();
 }
@@ -76,11 +78,16 @@ static void Reshape(int width, int height)
 static void Key(unsigned char key, int x, int y)
 {
    switch (key) {
-    case 27:
-       exit(1);
+   case 27:
+      exit(1);
    case 'c':
       cull();
       break;
+   case 'f':
+      front = ((front == GL_CCW) ? GL_CW : GL_CCW);
+      glFrontFace(front);
+      printf("front face = %s\n", front == GL_CCW ? "GL_CCW" : "GL_CW");
+      break;
    default:
       return;
    }
@@ -92,7 +99,7 @@ static void Draw(void)
    glClear(GL_COLOR_BUFFER_BIT); 
 
    glBegin(GL_TRIANGLES);
-   /* back-facing */
+   /* CCW / front-facing */
    glColor3f(0,0,.7); 
    glVertex3f(-0.1, -0.9, -30.0);
    glColor3f(.8,0,0); 
@@ -100,7 +107,7 @@ static void Draw(void)
    glColor3f(0,.9,0); 
    glVertex3f(-0.9,  0.0, -30.0);
 
-   /* front-facing */
+   /* CW / back-facing */
    glColor3f(0,0,.7); 
    glVertex3f( 0.1, -0.9, -30.0);
    glColor3f(.8,0,0); 
@@ -152,7 +159,7 @@ int main(int argc, char **argv)
     type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
     glutInitDisplayMode(type);
 
-    if (glutCreateWindow("First Tri") == GL_FALSE) {
+    if (glutCreateWindow(*argv) == GL_FALSE) {
        exit(1);
     }