GLXFBConfig GLXGLSupport::getFBConfigFromContext(::GLXContext context) { GLXFBConfig fbConfig = 0; if (GLXEW_VERSION_1_3) { int fbConfigAttrib[] = { GLX_FBCONFIG_ID, 0, None }; GLXFBConfig *fbConfigs; int nElements = 0; glXQueryContext(mGLDisplay, context, GLX_FBCONFIG_ID, &fbConfigAttrib[1]); fbConfigs = glXChooseFBConfig(mGLDisplay, DefaultScreen(mGLDisplay), fbConfigAttrib, &nElements); if (nElements) { fbConfig = fbConfigs[0]; XFree(fbConfigs); } } else if (GLXEW_EXT_import_context && GLXEW_SGIX_fbconfig) { VisualID visualid; if (glXQueryContextInfoEXT(mGLDisplay, context, GLX_VISUAL_ID, (int*)&visualid)) { fbConfig = getFBConfigFromVisualID(visualid); } } return fbConfig; }
static bool try_query(GLXContext ctx, int attribute, const char *attribute_string, int expected_error, int expected_value) { bool pass = true; int value = 0xDEADBEEF; int err; err = glXQueryContextInfoEXT(dpy, ctx, attribute, &value); XSync(dpy, 0); if (err != expected_error) { fprintf(stderr, "Query of %s had error %d, but %d was expected.\n", attribute_string, err, expected_error); pass = false; } /* There is no way in GLX_SGIX_fbconfig to get an XID from a * GLXFBConfig. As a result, there's no way to verify * glXQueryContextInfoEXT has returned the correct value. The * required functionality was not added until GLX 1.3. */ if (attribute != GLX_FBCONFIG_ID_SGIX) { if (expected_error != Success) expected_value = 0xDEADBEEF; if (value != expected_value) { fprintf(stderr, "Query of %s had value %d, but %d was " "expected.\n", attribute_string, value, expected_value); pass = false; } } else { if (value == 0xDEADBEEF) { fprintf(stderr, "Query of %s did not set a value.\n", attribute_string); pass = false; } } /* No GLX protocol error should be generated. */ pass = validate_glx_error_code(Success, -1) && pass; return pass; }