X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=apps%2Fgl%2Ftri.c;h=faa794b7f7bfed43cdbbd54c5ead1abe505ebf53;hb=HEAD;hp=c6c1849607b3ac6367541a58f5e414838335602f;hpb=68f16d73f902506982815195220215866640ccdb;p=apitrace-tests diff --git a/apps/gl/tri.c b/apps/gl/tri.c index c6c1849..faa794b 100644 --- a/apps/gl/tri.c +++ b/apps/gl/tri.c @@ -41,32 +41,54 @@ 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(); @@ -81,10 +103,14 @@ static void Draw(void) exit(0); } -int main(int argc, char **argv) + +int +main(int argc, char **argv) { GLenum type; + parseArgs(argc, argv); + glutInit(&argc, argv); glutInitWindowSize(250, 250);