/** * compile with: gcc -o displayMultiple02 displayMultiple02.c -lX11 -lGL */ #include #include #include #include #include #include static void testOrder(int reverseDestroyOrder, const char * msg); static int useXLockDisplay = 0; int main(int nargs, char **vargs) { int arg=1; while(argscreen), vi->visual, AllocNone); attr.colormap = cmap; attr.border_pixel = 0; /* create a window in window mode*/ attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask; *rWin = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, width, height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &attr); XMapRaised(dpy, *rWin); } void createGLWinNew(Display *dpy, int width, int height, Window *rWin, GLXContext *rCtx) { int screen = DefaultScreen(dpy); Colormap cmap; XSetWindowAttributes attr; // create configs int nelements; GLXFBConfig *fbconfigs = glXChooseFBConfig(dpy,screen,attrListDblNew,&nelements ); // get visual XVisualInfo *vi = glXGetVisualFromFBConfig(dpy,*fbconfigs); /* create a GLX context */ *rCtx = glXCreateNewContext(dpy, *fbconfigs, GLX_RGBA_TYPE, 0, GL_TRUE); /* create a color map */ cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); attr.colormap = cmap; attr.border_pixel = 0; /* create a window in window mode*/ attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask; *rWin = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, width, height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &attr); XMapRaised(dpy, *rWin); } void useGL(Display *dpy, Window win, GLXContext ctx, int width, int height) { glXMakeCurrent(dpy, win, ctx); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glXSwapBuffers(dpy, win); glXMakeCurrent(dpy, 0, 0); }