/* This case is to test the glXCreateWindow() support. * compile: * gcc -o test_glXCreateWindow test_glXCreateWindow.c -lGL * run: * LIBGL_ALWAYS_SOFTWARE=yes ./test_glXCreateWindow * * Result: * The case should have no any output suppose the API works well. * Right now the mesa will report: * failed to create drawable */ #include #include #include #include #include #include static const int attributes[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DOUBLEBUFFER, GL_TRUE, None }; int main(void) { GLXFBConfig config = NULL; GLXFBConfig *configs = NULL; Window dummy_xwin; XVisualInfo *xvisinfo; int major; int minor; int n_configs, i; GLXDrawable dummy_drawable; GLXWindow dummy_glxwin; Display *xdisplay = XOpenDisplay(NULL); int xscreen_num = DefaultScreen (xdisplay); Window root_xwin = DefaultRootWindow (xdisplay); configs = glXChooseFBConfig (xdisplay, xscreen_num, attributes, &n_configs); if (configs) { config = configs[0]; XFree (configs); } else { fprintf (stderr, "Unable to find config!\n"); return; } xvisinfo = glXGetVisualFromFBConfig (xdisplay, config); if (xvisinfo == None) { fprintf (stderr, "Unable to retrieve the X11 visual!\n"); return; } dummy_xwin = XCreateWindow (xdisplay, root_xwin, 100, 100, 200, 200, 0, xvisinfo->depth, CopyFromParent, xvisinfo->visual, None, None); if (glXQueryVersion (xdisplay, &major, &minor) && major == 1 && minor >= 3) { dummy_glxwin = glXCreateWindow (xdisplay, config, dummy_xwin, NULL); } else { fprintf (stderr, "The test cannot be performed in current GLX version : %d.%d\n", major, minor); } return; }