]> git.cworth.org Git - apitrace-tests/blobdiff - apps/gl/tri.c
Test single/double buffering.
[apitrace-tests] / apps / gl / tri.c
index 005c227e5e029bed60358ff5a1f96e6b03ee81a8..baff0246c2254e07ae90898ef54a5c488b9c46a9 100644 (file)
 #endif
 
 
-#define CI_OFFSET_1 16
-#define CI_OFFSET_2 32
-
-
 static GLboolean doubleBuffer = GL_TRUE;
 static int win;
 
-static void Init(void)
+static void parseArgs(int argc, char** argv)
 {
-   fprintf(stdout, "GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
-   fprintf(stdout, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
-   fprintf(stdout, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
-   fflush(stdout);
+   int i;
 
-   glClearColor(0.3, 0.1, 0.3, 0.0);
+   for (i = 1; i < argc; ++i) {
+      const char *arg = argv[i];
+      if (strcmp(arg, "-sb") == 0) {
+         doubleBuffer = GL_FALSE;
+      } else if (strcmp(arg, "-db") == 0) {
+         doubleBuffer = GL_TRUE;
+      } else {
+         fprintf(stderr, "error: unknown arg %s\n", arg);
+         exit(1);
+      }
+   }
+}
+
+static void Init(void)
+{
+   glClearColor(0.3, 0.1, 0.3, 1.0);
 }
 
 static void Reshape(int width, int height)
@@ -84,39 +92,21 @@ static void Draw(void)
    if (doubleBuffer) {
       glutSwapBuffers();
    }
-   
-   glutDestroyWindow(win);
-}
 
-static GLenum Args(int argc, char **argv)
-{
-   GLint i;
+   glutDestroyWindow(win);
 
-   for (i = 1; i < argc; i++) {
-      if (strcmp(argv[i], "-sb") == 0) {
-         doubleBuffer = GL_FALSE;
-      } else if (strcmp(argv[i], "-db") == 0) {
-         doubleBuffer = GL_TRUE;
-      } else {
-         fprintf(stderr, "%s (Bad option).\n", argv[i]);
-         return GL_FALSE;
-      }
-   }
-   return GL_TRUE;
+   exit(0);
 }
 
 int main(int argc, char **argv)
 {
    GLenum type;
 
-   glutInit(&argc, argv);
+   parseArgs(argc, argv);
 
-   if (Args(argc, argv) == GL_FALSE) {
-      exit(1);
-   }
+   glutInit(&argc, argv);
 
-   glutInitWindowPosition(0, 0);
-   glutInitWindowSize( 250, 250);
+   glutInitWindowSize(250, 250);
 
    type = GLUT_RGB | GLUT_ALPHA;
    type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;