Index: xc/programs/glxgears/glxgears.c =================================================================== RCS file: /cvs/xorg/xc/programs/glxgears/glxgears.c,v retrieving revision 1.10 diff -u -2 -0 -r1.10 glxgears.c --- xc/programs/glxgears/glxgears.c 7 Mar 2005 19:39:57 -0000 1.10 +++ xc/programs/glxgears/glxgears.c 1 Apr 2005 00:40:47 -0000 @@ -111,40 +111,41 @@ fprintf (stderr, "-print\t\tUse printer instead of video card for output.\n"); fprintf (stderr, "-printer printername\tname of printer to use.\n"); fprintf (stderr, "-printfile printername\tOutput file for print job.\n"); fprintf (stderr, "-numpages count\tNumber of pages to print.\n"); fprintf (stderr, "-degperpage deg\tRotate gears degree per page.\n"); #endif /* BUILD_PRINTSUPPORT */ fprintf (stderr, "-info\t\tPrint additional GLX information.\n"); fprintf (stderr, "-singletooth\tDraw only one tooth for each gear (for debugging etc.).\n"); fprintf (stderr, "-h\t\tPrint this help page.\n"); fprintf (stderr, "-v\t\tVerbose output.\n"); fprintf (stderr, "\n"); exit(EXIT_FAILURE); } static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; static GLint gear1, gear2, gear3; static GLfloat angle = 0.0; static GLint speed = 60; static int singletooth = 0, paused = 0; static GLboolean printInfo = GL_FALSE; +static VisualID reqVisID = 0; /* * * Draw a gear wheel. You'll probably want to call this function when * building a display list since we do a lot of trig here. * * Input: inner_radius - radius of hole at center * outer_radius - radius at center of teeth * width - width of gear * teeth - number of teeth * tooth_depth - depth of tooth */ static void gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth) { GLint i; GLfloat r0, r1, r2, maxr2, minr2; GLfloat angle, da; GLfloat u, v, len; @@ -375,44 +376,58 @@ { int attrib[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 1, None }; int scrnum; XSetWindowAttributes attr; unsigned long mask; Window root; Window win; GLXContext ctx; XVisualInfo *visinfo; GLint max[2] = { 0, 0 }; scrnum = XScreenNumberOfScreen(scr); root = XRootWindow(dpy, scrnum); - visinfo = glXChooseVisual( dpy, scrnum, attrib ); - if (!visinfo) { - fprintf(stderr, "%s: Error: couldn't get an RGB, Double-buffered visual.\n", ProgramName); - exit(EXIT_FAILURE); + if (reqVisID == 0) { + visinfo = glXChooseVisual( dpy, scrnum, attrib ); + if (!visinfo) { + fprintf(stderr, "%s: Error: couldn't get an RGB, Double-buffered visual.\n", ProgramName); + exit(EXIT_FAILURE); + } + } + else + { + XVisualInfo vinfo_template; + int dummy; + vinfo_template.visualid = reqVisID; + vinfo_template.screen = scrnum; + visinfo = XGetVisualInfo(dpy, VisualIDMask|VisualScreenMask, &vinfo_template, &dummy); + if (!visinfo) { + fprintf(stderr, "%s: Error: couldn't get visual %x.\n", ProgramName, (int)reqVisID); + exit(EXIT_FAILURE); + } } /* window attributes */ attr.background_pixel = 0; attr.border_pixel = 0; attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow( dpy, root, x, y, width, height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr ); /* set hints and properties */ { XSizeHints sizehints; sizehints.x = x; sizehints.y = y; sizehints.width = width; sizehints.height = height; @@ -673,40 +688,48 @@ errno = 0; /* reset errno to catch |atoi()|-errors */ numPages = atoi(argv[i]); if ((numPages <= 0) || (errno != 0)) usage(); doPrint = True; } else if (!strncmp("-degperpage", arg, len)) { if (++i >= argc) usage(); errno = 0; /* reset errno to catch |atof()|-errors */ degperpage = atof(argv[i]); if (errno != 0) usage(); doPrint = True; } #endif /* BUILD_PRINTSUPPORT */ else if (!strncmp("-v", arg, len)) { verbose = True; printInfo = GL_TRUE; } + else if (!strncmp("-visid", arg, len)) { + if (++i >= argc) + usage(); + errno = 0; /* reset errno to catch |strtol()|-errors */ + reqVisID = strtol(argv[i], NULL, 0); + if ((reqVisID == 0) || (errno != 0)) + usage(); + } else if (!strncmp("-singletooth", arg, len)) { singletooth = True; } else if( !strncmp("-debug_use_threadsafe_api", arg, len) ) { use_threadsafe_api = True; } else if (!strcmp(argv[i], "-h")) { usage(); } else { fprintf(stderr, "%s: Unsupported option '%s'.\n", ProgramName, argv[i]); usage(); } } /* Init X threading API on demand (for debugging) */ if( use_threadsafe_api ) {