diff --git a/progs/xdemos/glxgears.c b/progs/xdemos/glxgears.c index 8db717f..52c697f 100644 --- a/progs/xdemos/glxgears.c +++ b/progs/xdemos/glxgears.c @@ -100,6 +100,7 @@ static GLfloat angle = 0.0; static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */ static GLboolean stereo = GL_FALSE; /* Enable stereo. */ static GLboolean animate = GL_TRUE; /* Animation */ +static GLboolean teartest = GL_FALSE; /* Run a tear test. */ static GLfloat eyesep = 5.0; /* Eye separation. */ static GLfloat fix_point = 40.0; /* Fixation point distance. */ static GLfloat left, right, asp; /* Stereo frustum params. */ @@ -312,7 +313,53 @@ draw_gears(void) draw(); } } - +void draw_tear_test(int n) +{ + GLint params[4]; + GLint matrixmode; + GLboolean depthtest; + GLboolean lighting; + int bw = 10; + int w,h,x0; + glGetIntegerv(GL_VIEWPORT, params); + glGetIntegerv(GL_MATRIX_MODE, &matrixmode); + glGetBooleanv(GL_DEPTH_TEST, &depthtest); + glGetBooleanv(GL_LIGHTING, &lighting); + if(depthtest)glDisable(GL_DEPTH_TEST); + if(lighting)glDisable(GL_LIGHTING); + w = params[2]; + h = params[3]; + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, w, h, 0, 0, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + if (n & 1)glColor3f(1.0,1.0,1.0); + else glColor3f(0,0,0); + + glBegin(GL_QUADS); + glVertex2i(0, 0); + glVertex2i(0, h); + glVertex2i(bw, h); + glVertex2i(bw, 0); + + x0 = w - bw; + glVertex2i(x0, 0); + glVertex2i(x0, h); + glVertex2i(x0 + w, h); + glVertex2i(x0 + w, 0); + glEnd(); + + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(matrixmode); + if(depthtest)glEnable(GL_DEPTH_TEST); + if(lighting)glEnable(GL_LIGHTING); +} /** Draw single frame, do SwapBuffers, compute FPS */ static void @@ -335,6 +382,7 @@ draw_frame(Display *dpy, Window win) } draw_gears(); + if(teartest)draw_tear_test(frames); glXSwapBuffers(dpy, win); frames++; @@ -637,6 +685,7 @@ usage(void) printf(" -fullscreen run in fullscreen mode\n"); printf(" -info display OpenGL renderer info\n"); printf(" -geometry WxH+X+Y window geometry\n"); + printf(" -teartest Output small alternately colored sidebars.\n"); } @@ -666,6 +715,9 @@ main(int argc, char *argv[]) else if (strcmp(argv[i], "-fullscreen") == 0) { fullscreen = GL_TRUE; } + else if (strcmp(argv[i], "-teartest") == 0) { + teartest = GL_TRUE; + } else if (i < argc-1 && strcmp(argv[i], "-geometry") == 0) { XParseGeometry(argv[i+1], &x, &y, &winWidth, &winHeight); i++;