demos: delete vertex array objects upon exit
[mesa.git] / progs / demos / isosurf.c
index 10f94b6ace236081c914ca8ca825490a190bdb3a..e280d8f507c553d2d4201cf9176b6ef4d8325950 100644 (file)
@@ -33,7 +33,7 @@
 #include <windows.h>
 #undef CLIP_MASK
 #endif
-#define GL_GLEXT_PROTOTYPES
+#include <GL/glew.h>
 #include "GL/glut.h"
 
 #include "readtex.h"
@@ -69,6 +69,7 @@
 #define NO_STIPPLE     0x08000000
 #define POLYGON_FILL   0x10000000
 #define POLYGON_LINE   0x20000000
+#define POLYGON_POINT  0x40000000
 
 #define LIGHT_MASK             (LIT|UNLIT|REFLECT)
 #define FILTER_MASK            (POINT_FILTER|LINEAR_FILTER)
@@ -81,7 +82,7 @@
 #define SHADE_MASK             (SHADE_SMOOTH|SHADE_FLAT)
 #define FOG_MASK               (FOG|NO_FOG)
 #define STIPPLE_MASK           (STIPPLE|NO_STIPPLE)
-#define POLYGON_MASK           (POLYGON_FILL|POLYGON_LINE)
+#define POLYGON_MASK           (POLYGON_FILL|POLYGON_LINE|POLYGON_POINT)
 
 #define MAXVERTS 10000
 static GLint maxverts = MAXVERTS;
@@ -147,7 +148,7 @@ static void read_surface( char *filename )
 static void print_flags( const char *msg, GLuint flags ) 
 {
    fprintf(stderr, 
-          "%s (0x%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+          "%s (0x%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
           msg, flags,
           (flags & GLVERTEX) ? "glVertex, " : "",
           (flags & DRAW_ARRAYS) ? "glDrawArrays, " : "",
@@ -166,7 +167,8 @@ static void print_flags( const char *msg, GLuint flags )
           (flags & MATERIALS) ? "materials, " : "",
           (flags & FOG) ? "fog, " : "",
           (flags & STIPPLE) ? "stipple, " : "",
-          (flags & POLYGON_LINE) ? "polygon mode line, " : "");
+          (flags & POLYGON_LINE) ? "polygon mode line, " : "",
+          (flags & POLYGON_POINT) ? "polygon mode point, " : "");
 }
 
 
@@ -711,9 +713,12 @@ static void ModeMenu(int m)
       if (m & POLYGON_FILL) {
         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
       }
-      else {
+      else if (m & POLYGON_LINE) {
         glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
       }
+      else {
+        glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+      }
    }
 
 #ifdef GL_EXT_vertex_array
@@ -1033,7 +1038,6 @@ static GLint Args(int argc, char **argv)
 int main(int argc, char **argv)
 {
    GLenum type;
-   char *extensions;
 
    GLuint arg_mode = Args(argc, argv);
 
@@ -1055,15 +1059,15 @@ int main(int argc, char **argv)
       exit(0);
    }
 
-   /* Make sure server supports the vertex array extension */
-   extensions = (char *) glGetString( GL_EXTENSIONS );
+   glewInit();
 
-   if (!strstr( extensions, "GL_EXT_vertex_array" ))
+   /* Make sure server supports the vertex array extension */
+   if (!GLEW_EXT_vertex_array)
    {
       printf("Vertex arrays not supported by this renderer\n");
       allowed &= ~(LOCKED|DRAW_ARRAYS|DRAW_ELTS|ARRAY_ELT);
    }
-   else if (!strstr( extensions, "GL_EXT_compiled_vertex_array" ))
+   else if (!GLEW_EXT_compiled_vertex_array)
    {
       printf("Compiled vertex arrays not supported by this renderer\n");
       allowed &= ~LOCKED;
@@ -1090,6 +1094,7 @@ int main(int argc, char **argv)
    glutAddMenuEntry("", 0);
    glutAddMenuEntry("Polygon Mode Fill",     POLYGON_FILL);
    glutAddMenuEntry("Polygon Mode Line",     POLYGON_LINE);
+   glutAddMenuEntry("Polygon Mode Points",   POLYGON_POINT);
    glutAddMenuEntry("", 0);
    glutAddMenuEntry("Point Filtered",        POINT_FILTER);
    glutAddMenuEntry("Linear Filtered",       LINEAR_FILTER);