



         #include <X11/Intrinsic.h>
         #include <GL/glx.h>
         #include <GL/gl.h>
         #include <unistd.h>

         static int attributeList[] = { GLX_RGBA,
           GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None };

         static Bool WaitForNotify (Display * d, XEvent * e, char *arg) {
           return (e->type == MapNotify) && (e->xmap.window == (Window) arg);
         }

         int main (int argc, char **argv) {
           Display *dpy;
           XVisualInfo *vi;
           Colormap cmap;
           XSetWindowAttributes swa;
           Window win;
           GLXContext cx;
           XEvent event;

           dpy = XOpenDisplay (0);

           XBell(dpy, 100);

           vi = glXChooseVisual (dpy, DefaultScreen (dpy), attributeList);

           cx = glXCreateContext (dpy, vi, 0, GL_TRUE);

           cmap = XCreateColormap (dpy, RootWindow (dpy, vi->screen),
             vi->visual, AllocNone);

           swa.colormap = cmap;
           swa.border_pixel = 0;
           swa.event_mask = StructureNotifyMask;
           win = XCreateWindow (dpy, RootWindow (dpy, vi->screen), 0, 0, 500,
             500, 0, vi->depth, InputOutput, vi->visual,
             CWBorderPixel | CWColormap | CWEventMask, &swa);
           XMapWindow (dpy, win);
           XIfEvent (dpy, &event, WaitForNotify, (char *) win);

           glXMakeCurrent (dpy, win, cx);

           glClearColor (1, 1, 0, 1);
           glClear (GL_COLOR_BUFFER_BIT);
           glFlush ();

           sleep (10);

           return 0;
         }

