void get_context_IDs(void) { directID = None; if (directCtx != NULL) { directID = glXGetContextIDEXT(directCtx); } indirectID = None; if (indirectCtx != NULL) { indirectID = glXGetContextIDEXT(indirectCtx); } }
static bool try_get_context_id(GLXContext ctx, enum context_mode mode) { bool pass = true; GLXContextID id = glXGetContextIDEXT(ctx); XSync(dpy, 0); if (mode != invalid && id == None) { fprintf(stderr, "Could not get context ID for %s context.\n", context_mode_name(mode)); pass = false; } else if (mode == invalid && id != None) { fprintf(stderr, "Got a context ID for %s context.\n", context_mode_name(mode)); pass = false; } /* The glXGetContextIDEXT man page says: * * "GLXBadContext is generated if ctx does not refer to a valid * context." * * However, glXGetContextIDEXT doesn't take a Display. If the context * is invalid and no context is current, it is impossible for * glXGetContextIDEXT to get a Display. Without a Display, it is * impossible to generate a protocol error! */ pass = validate_glx_error_code(Success, -1) && pass; return pass; }
int main(int argc, char **argv) { bool pass = true; GLXContext ctx; GLX_EXT_import_context_setup(); /* Try the simple stuff. */ pass = try_query(indirectCtx, GLX_SHARE_CONTEXT_EXT, "GLX_SHARE_CONTEXT_EXT", Success, 0) && pass; pass = try_query(indirectCtx, GLX_SCREEN_EXT, "GLX_SCREEN_EXT", Success, DefaultScreen(dpy)) && pass; pass = try_query(indirectCtx, GLX_VISUAL_ID_EXT, "GLX_VISUAL_ID_EXT", Success, visinfo->visualid) && pass; pass = try_query(indirectCtx, 0xffff0000, "0xffff0000 (invalid)", GLX_BAD_ATTRIBUTE, 0) && pass; /* Create a second indirect-rendering context, and have it share the * first indirect-rendering context. The XID of the share conext for * the original context should be unchanged. */ ctx = glXCreateContext(dpy, visinfo, indirectCtx, False); assert(ctx != NULL); pass = try_query(indirectCtx, GLX_SHARE_CONTEXT_EXT, "GLX_SHARE_CONTEXT_EXT", Success, 0) && pass; pass = try_query(ctx, GLX_SHARE_CONTEXT_EXT, "GLX_SHARE_CONTEXT_EXT", Success, glXGetContextIDEXT(indirectCtx)) && pass; if (piglit_is_glx_extension_supported(dpy, "GLX_SGIX_fbconfig")) { pass = try_query(indirectCtx, GLX_FBCONFIG_ID_SGIX, "GLX_FBCONFIG_ID_SGIX", Success, 0) && pass; } GLX_EXT_import_context_teardown(); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); return 0; }