// build with: // $ gcc -std=gnu99 `pkg-config --cflags --libs gl ` q.c #define _XOPEN_SOURCE 500 #define GL_GLEXT_PROTOTYPES #include #include #include #include int main(void) { Display *dpy = XOpenDisplay(NULL); Window root = DefaultRootWindow(dpy); Window wnd1 = XCreateSimpleWindow(dpy, root, 0, 0, 10, 10, 0, 0, 0); Window wnd2 = XCreateSimpleWindow(dpy, root, 0, 0, 10, 10, 0, 0, 0); GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None }; XVisualInfo *vi; vi = glXChooseVisual(dpy, 0, att); if (NULL == vi) { fprintf(stderr, "failed to choose visual\n"); return 1; } GLXContext glc = glXCreateContext(dpy, vi, NULL, GL_TRUE); printf("playing with context\n"); for (int k = 0; k < 1000; k ++) { printf("."); fflush(stdout); for (int j = 0; j < 100; j ++) { glXMakeCurrent(dpy, wnd1, glc); glXMakeCurrent(dpy, wnd2, glc); glXSwapBuffers(dpy, wnd2); } } printf("done\n"); return 0; }