Mesa (dlist-statechange-shortcircuit): progs/isosurf: add materials mode for glVertex + TRISTRIP

Keith Whitwell keithw at kemper.freedesktop.org
Tue Jun 30 16:06:04 UTC 2009


Module: Mesa
Branch: dlist-statechange-shortcircuit
Commit: a9ae89d104161c1052beda7e3dcb21b8b7af5ba3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9ae89d104161c1052beda7e3dcb21b8b7af5ba3

Author: Keith Whitwell <keithw at vmware.com>
Date:   Sun May 31 19:07:21 2009 -0700

progs/isosurf: add materials mode for glVertex + TRISTRIP

---

 progs/demos/isosurf.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c
index e280d8f..6923ca2 100644
--- a/progs/demos/isosurf.c
+++ b/progs/demos/isosurf.c
@@ -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:




More information about the mesa-commit mailing list