objview: check GL version/extension
authorBrian Paul <brianp@vmware.com>
Thu, 1 Oct 2009 19:05:13 +0000 (13:05 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 1 Oct 2009 19:14:49 +0000 (13:14 -0600)
progs/objviewer/objview.c

index a2b172b9362876297e61a12b26b52a2e58aa769f..ad25e751a772d6ade8452be0ea8909dea9ecfc07 100644 (file)
@@ -148,7 +148,7 @@ init_model(void)
    glmFacetNormals(Model);
    if (Model->numnormals == 0) {
       GLfloat smoothing_angle = 90.0;
-      printf("Generating normals.");
+      printf("Generating normals.\n");
       glmVertexNormals(Model, smoothing_angle);
    }
 
@@ -432,6 +432,32 @@ Motion(int x, int y)
 }
 
 
+static void
+DoFeatureChecks(void)
+{
+   char *version = (char *) glGetString(GL_VERSION);
+   if (version[0] == '1') {
+      /* check for individual extensions */
+      if (!glutExtensionSupported("GL_ARB_texture_cube_map")) {
+         printf("Sorry, GL_ARB_texture_cube_map is required.\n");
+         exit(1);
+      }
+      if (!glutExtensionSupported("GL_ARB_vertex_shader")) {
+         printf("Sorry, GL_ARB_vertex_shader is required.\n");
+         exit(1);
+      }
+      if (!glutExtensionSupported("GL_ARB_fragment_shader")) {
+         printf("Sorry, GL_ARB_fragment_shader is required.\n");
+         exit(1);
+      }
+      if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) {
+         printf("Sorry, GL_ARB_vertex_buffer_object is required.\n");
+         exit(1);
+      }
+   }
+}
+
+
 int
 main(int argc, char** argv)
 {
@@ -452,6 +478,8 @@ main(int argc, char** argv)
 
    glewInit();
 
+   DoFeatureChecks();
+
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);