- int attrs[][20] = {
- { GLX_RGBA, R, 8, G, 8, B, 8, D, 8, DB, 0 }, /* rgb double */
- { GLX_RGBA, R, 4, G, 4, B, 4, D, 4, DB, 0 },
- { GLX_RGBA, R, 2, G, 2, B, 2, D, 2, DB, 0 },
- { GLX_RGBA, R, 8, G, 8, B, 8, D, 8, 0 }, /* rgb single */
- { GLX_RGBA, R, 4, G, 4, B, 4, D, 4, 0 },
- { GLX_RGBA, R, 2, G, 2, B, 2, D, 2, 0 },
- { I, 8, D, 8, DB, 0 }, /* cmap double */
- { I, 4, D, 4, DB, 0 },
- { I, 8, D, 8, 0 }, /* cmap single */
- { I, 4, D, 4, 0 },
- { GLX_RGBA, R, 1, G, 1, B, 1, D, 1, 0 } /* monochrome */
- };
-
- int i;
- for (i = 0; i < sizeof(attrs)/sizeof(*attrs); i++)
- {
- XVisualInfo *vi = glXChooseVisual (dpy, screen, attrs[i]);
- if (vi)
- {
- visual = vi->visual;
- XFree (vi);
- break;
- }
- }
- if (!visual)
- {
- fprintf (stderr, "%s: unable to find a GL visual\n", progname);
- exit (1);
- }
- }
-
-
- if (x == undef) x = 0;
- if (y == undef) y = 0;
-
- xswa_mask = (CWEventMask | CWColormap |
- CWBackPixel | CWBackingPixel | CWBorderPixel );
- xswa.colormap = XCreateColormap (dpy, RootWindow (dpy, screen),
- visual, AllocNone);
- xswa.background_pixel = BlackPixel (dpy, screen);
- xswa.backing_pixel = xswa.background_pixel;
- xswa.border_pixel = xswa.background_pixel;
- xswa.event_mask = (KeyPressMask | ButtonPressMask | StructureNotifyMask);
-
- window = XCreateWindow (dpy, RootWindow (dpy, screen),
- x, y, w, h, 0,
- visual_depth (dpy, screen, visual),
- InputOutput, visual,
- xswa_mask, &xswa);
-
- {
- XWMHints wmhints;
-
- XTextProperty tp1, tp2;
- char *v = make_title_string ();
- XStringListToTextProperty (&v, 1, &tp1);
- XStringListToTextProperty (&progclass, 1, &tp2);
- wmhints.flags = InputHint;
- wmhints.input = True;
- XSetWMProperties (dpy, window, &tp1, &tp2, argv, *argc, &hints,
- &wmhints, 0);
- free (v);
- }
-
- XChangeProperty (dpy, window, XA_WM_PROTOCOLS, XA_ATOM, 32,
- PropModeReplace,
- (unsigned char *) &XA_WM_DELETE_WINDOW, 1);
-
- XMapRaised (dpy, window);
- XSync (dpy, False);
- }
-
-
- /* Now hook up to GLX */
- {
- XVisualInfo vi_in, *vi_out;
- int out_count;
- vi_in.screen = screen;
- vi_in.visualid = XVisualIDFromVisual (visual);
- vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
- &vi_in, &out_count);
- if (! vi_out) abort ();
-
- glx_context = glXCreateContext (dpy, vi_out, 0, GL_TRUE);
- XFree((char *) vi_out);
-
- if (!glx_context)
- {
- fprintf(stderr, "%s: couldn't create GL context for root window.\n",
- progname);
- exit(1);
- }
-
- glXMakeCurrent (dpy, window, glx_context);
- }
-
- setup_window();
- win_reshape(w, h);
-
- return 1;
-}
-
-static void setup_window(void)
-{