progs/isosurf: add materials mode for glVertex + TRISTRIP
authorKeith Whitwell <keithw@vmware.com>
Mon, 1 Jun 2009 02:07:21 +0000 (19:07 -0700)
committerKeith Whitwell <keithw@vmware.com>
Tue, 30 Jun 2009 15:14:08 +0000 (16:14 +0100)
progs/demos/isosurf.c

index e280d8f507c553d2d4201cf9176b6ef4d8325950..6923ca2bba84b8aab5e78703e5e83df076367f2e 100644 (file)
@@ -514,12 +514,27 @@ static void draw_surface( unsigned int with_state )
       break;
 
    case (GLVERTEX|STRIPS):
-      glBegin( GL_TRIANGLE_STRIP );
-      for (i=0;i<numverts;i++) {
-         glNormal3fv( &data[i][3] );
-         glVertex3fv( &data[i][0] );
+      if (with_state & MATERIALS) {
+         glBegin( GL_TRIANGLE_STRIP );
+         for (i=0;i<numverts;i++) {
+            if (i % 600 == 0 && i != 0) {
+               unsigned j = i / 600;
+               glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
+               glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
+            }
+            glNormal3fv( &data[i][3] );
+            glVertex3fv( &data[i][0] );
+         }
+         glEnd();
+      }
+      else {
+         glBegin( GL_TRIANGLE_STRIP );
+         for (i=0;i<numverts;i++) {
+            glNormal3fv( &data[i][3] );
+            glVertex3fv( &data[i][0] );
+         }
+         glEnd();
       }
-      glEnd();
       break;
 
    default: