-Visual *
-get_gl_visual (Screen *screen, char *name, char *class)
-{
- char *string = get_string_resource (name, class);
- XVisualInfo *vi = 0;
- Bool done_once = False;
-
- AGAIN:
- if (!string || !*string ||
- !strcmp (string, "best") ||
- !strcmp (string, "color") ||
- !strcmp (string, "default"))
- {
- Display *dpy = DisplayOfScreen (screen);
- int screen_num = screen_number (screen);
- int attrs[20];
- int i = 0;
- Bool dbuf_p = !get_boolean_resource ("noBuffer", "NoBuffer");
-
- done_once = True;
-
- attrs[i++] = GLX_RGBA;
- attrs[i++] = GLX_RED_SIZE; attrs[i++] = 1;
- attrs[i++] = GLX_GREEN_SIZE; attrs[i++] = 1;
- attrs[i++] = GLX_BLUE_SIZE; attrs[i++] = 1;
- attrs[i++] = GLX_DEPTH_SIZE; attrs[i++] = 1;
- if (dbuf_p)
- attrs[i++] = GLX_DOUBLEBUFFER;
- attrs[i++] = 0;
-
- vi = glXChooseVisual (dpy, screen_num, attrs);
- if (vi) goto DONE;
-
- /* Try without double-buffering. */
- attrs[i - 1] = 0;
- vi = glXChooseVisual (dpy, screen_num, attrs);
- if (vi) goto DONE;
-
- /* Try mono. */
- i = 0;
- if (dbuf_p)
- attrs[i++] = GLX_DOUBLEBUFFER;
- attrs[i++] = 0;
- vi = glXChooseVisual (dpy, screen_num, attrs);
- if (vi) goto DONE;
-
- /* Try mono without double-buffering. */
- attrs[0] = 0;
- vi = glXChooseVisual (dpy, screen_num, attrs);
- }