]> git.cworth.org Git - apitrace-tests/blobdiff - apps/gl/tri.c
Add a tri glsl sample.
[apitrace-tests] / apps / gl / tri.c
index ea3b595550f4193f3d8e56d4f2ea4ae48547f091..faa794b7f7bfed43cdbbd54c5ead1abe505ebf53 100644 (file)
 static GLboolean doubleBuffer = GL_TRUE;
 static int win;
 
-static void Init(void)
+
+static void parseArgs(int argc, char** argv)
 {
-   glClearColor(0.3, 0.1, 0.3, 1.0);
+   int i;
+
+   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 Reshape(int width, int height)
+
+static void
+Init(void)
 {
+   glClearColor(0.3f, 0.1f, 0.3f, 1.0f);
+}
 
-   glViewport(0, 0, (GLint)width, (GLint)height);
 
+static void
+Reshape(int width, int height)
+{
+   glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
    glMatrixMode(GL_MODELVIEW);
 }
 
-static void Draw(void)
+
+static void
+Draw(void)
 {
    glClear(GL_COLOR_BUFFER_BIT); 
 
    glBegin(GL_TRIANGLES);
-   glColor3f(.8,0,0); 
+   glColor3f(.8, 0, 0); 
    glVertex3f(-0.9, -0.9, -30.0);
-   glColor3f(0,.9,0); 
+   glColor3f(0, .9, 0); 
    glVertex3f( 0.9, -0.9, -30.0);
-   glColor3f(0,0,.7); 
+   glColor3f(0, 0, .7); 
    glVertex3f( 0.0,  0.9, -30.0);
    glEnd();
 
@@ -75,20 +97,23 @@ static void Draw(void)
    if (doubleBuffer) {
       glutSwapBuffers();
    }
-   
+
    glutDestroyWindow(win);
 
    exit(0);
 }
 
-int main(int argc, char **argv)
+
+int
+main(int argc, char **argv)
 {
    GLenum type;
 
+   parseArgs(argc, argv);
+
    glutInit(&argc, argv);
 
-   glutInitWindowPosition(0, 0);
-   glutInitWindowSize( 250, 250);
+   glutInitWindowSize(250, 250);
 
    type = GLUT_RGB | GLUT_ALPHA;
    type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;