void piglit_oml_sync_control_test_run(bool fullscreen, enum piglit_result (*draw)(Display *dpy)) { Display *dpy; GLXContext ctx; dpy = XOpenDisplay(NULL); if (dpy == NULL) { fprintf(stderr, "couldn't open display\n"); piglit_report_result(PIGLIT_FAIL); } piglit_require_glx_extension(dpy, "GLX_OML_sync_control"); piglit_glx_get_all_proc_addresses(procs, ARRAY_SIZE(procs)); visinfo = piglit_get_glx_visual(dpy); if (fullscreen) win = piglit_get_glx_window_fullscreen(dpy, visinfo); else win = piglit_get_glx_window(dpy, visinfo); ctx = piglit_get_glx_context(dpy, visinfo); glXMakeCurrent(dpy, win, ctx); piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); XMapWindow(dpy, win); piglit_glx_event_loop(dpy, draw); }
void GLX_EXT_import_context_setup(void) { const char *const names[] = { "glXGetCurrentDisplayEXT", "glXQueryContextInfoEXT", "glXGetContextIDEXT", "glXImportContextEXT", "glXFreeContextEXT" }; __GLXextFuncPtr *procedures[ARRAY_SIZE(names)] = { (__GLXextFuncPtr *) & __piglit_glXGetCurrentDisplayEXT, (__GLXextFuncPtr *) & __piglit_glXQueryContextInfoEXT, (__GLXextFuncPtr *) & __piglit_glXGetContextIDEXT, (__GLXextFuncPtr *) & __piglit_glXImportContextEXT, (__GLXextFuncPtr *) & __piglit_glXFreeContextEXT }; const char *vendor; dpy = piglit_get_glx_display(); /* NVIDIA incorrectly only list the extension in the client * extenstions list. If the extension is available for applications * to use, it is supposed to be included in the list returned by * glXQueryExtensionsString. * * The glXImportContextEXT manual page is somewhat clear on this * topic: * * "If _glxextstring(EXT_import_context) is included in the string * returned by glXQueryExtensionsString, when called with argument * GLX_EXTENSIONS, extension EXT_import_context is supported." * * The text is a little weird because the only parameters to * glXQueryExtensionsString are the display and the screen. */ vendor = glXGetClientString(dpy, GLX_VENDOR); if (strcmp("NVIDIA Corporation", vendor) == 0) { const char *const client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS); if (!piglit_is_extension_in_string(client_extensions, "GLX_EXT_import_context")) { fprintf(stderr, "Test requires GLX_EXT_import_context.\n"); piglit_report_result(PIGLIT_SKIP); } } else { piglit_require_glx_extension(dpy, "GLX_EXT_import_context"); } piglit_glx_get_all_proc_addresses(procedures, names, ARRAY_SIZE(names)); visinfo = piglit_get_glx_visual(dpy); directCtx = glXCreateContext(dpy, visinfo, NULL, True); if (directCtx == NULL) { fprintf(stderr, "Could not create initial direct-rendering context.\n"); piglit_report_result(PIGLIT_FAIL); } if (!glXIsDirect(dpy, directCtx)) { glXDestroyContext(dpy, directCtx); directCtx = NULL; } indirectCtx = glXCreateContext(dpy, visinfo, NULL, False); if (indirectCtx == NULL) { fprintf(stderr, "Could not create initial indirect-rendering " "context.\n"); piglit_report_result(PIGLIT_FAIL); } piglit_glx_get_error(dpy, NULL); old_handler = XSetErrorHandler(x_error_handler); }