Fix a quadstrip front/back-face inconsistancy.
authorBrian <brian.paul@tungstengraphics.com>
Sat, 15 Dec 2007 00:34:01 +0000 (17:34 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Tue, 18 Dec 2007 23:24:19 +0000 (16:24 -0700)
Only set front material colors to make it noticable if front/back-face
determination is incorrect anywhere.

progs/demos/engine.c

index 143b02a8894fc9686c0f6b8ac120fb0e87b292fd..393cd95988f72efe85fc70296814455cf45e1a61 100644 (file)
@@ -441,8 +441,8 @@ DrawConnector(float length, float thickness,
    for (i = 0; i <= 36; i++) {
       const int j = i % 36;
       glNormal3f(normals[j][0], normals[j][1], 0);
-      glVertex3f(points[j][0], points[j][1], z0);
       glVertex3f(points[j][0], points[j][1], z1);
+      glVertex3f(points[j][0], points[j][1], z0);
    }
    glEnd();
 }
@@ -741,7 +741,7 @@ DrawEngine(const Engine *eng, float crankAngle)
    glTranslatef(0, 0, -0.5 * crankLen);
 
    /* crankshaft */
-   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, CrankshaftColor);
+   glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, CrankshaftColor);
    glColor4fv(CrankshaftColor);
    DrawPositionedCrankshaft(eng, crankAngle);
 
@@ -760,12 +760,12 @@ DrawEngine(const Engine *eng, float crankAngle)
          rot += k * eng->V_Angle;
 
          /* piston */
-         glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, PistonColor);
+         glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, PistonColor);
          glColor4fv(PistonColor);
          DrawPositionedPiston(eng, rot);
 
          /* connecting rod */
-         glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, ConnRodColor);
+         glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ConnRodColor);
          glColor4fv(ConnRodColor);
          DrawPositionedConnectingRod(eng, rot);
       glPopMatrix();
@@ -780,7 +780,7 @@ DrawEngine(const Engine *eng, float crankAngle)
       }
       glEnable(GL_CULL_FACE);
 
-      glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, BlockColor);
+      glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlockColor);
       glColor4fv(BlockColor);
       if (eng->CrankList)
          glCallList(eng->BlockList);
@@ -1250,6 +1250,7 @@ Init(void)
 {
    const GLfloat lightColor[4] = { 0.7, 0.7, 0.7, 1.0 };
    const GLfloat specular[4] = { 0.8, 0.8, 0.8, 1.0 };
+   const GLfloat backColor[4] = { 1, 1, 0, 0 };
 
    Q = gluNewQuadric();
    gluQuadricNormals(Q, GLU_SMOOTH);
@@ -1261,10 +1262,14 @@ Init(void)
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
-   glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 40);
-   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
+   glMaterialf(GL_FRONT, GL_SHININESS, 40);
+   glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
    glEnable(GL_NORMALIZE);
 
+   glMaterialfv(GL_BACK, GL_DIFFUSE, backColor);
+#if 0
+   glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
+#endif
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
    InitViewInfo(&View);