static int handler(Display *dpy, XErrorEvent *err) { if (piglit_glx_get_error(dpy, err) != GLXBadDrawable) pass = 0; return 0; }
static int x_error_handler(Display *dpy, XErrorEvent *e) { x_error_code = e->error_code; glx_error_code = piglit_glx_get_error(dpy, e); return 0; }
static int expect_glxbaddrawable(Display *display, XErrorEvent *error) { if (piglit_glx_get_error(display, error) == GLXBadDrawable) { found_error_glxbaddrawable = true; } else { static char buf[256]; XGetErrorText(display, error->error_code, buf, 256); fprintf(stderr, "error: unexpected X error: %s\n", buf); piglit_report_result(PIGLIT_FAIL); } return 0; }
int main(int argc, char **argv) { Pixmap p; GLXPixmap g; GLXContext ctx; dpy = XOpenDisplay(NULL); if (dpy == NULL) { fprintf(stderr, "couldn't open display\n"); piglit_report_result(PIGLIT_FAIL); } piglit_glx_get_error(dpy, NULL); piglit_require_glx_version(dpy, 1, 3); visinfo = piglit_get_glx_visual(dpy); p = XCreatePixmap(dpy, DefaultRootWindow(dpy), piglit_width, piglit_height, visinfo->depth); g = glXCreateGLXPixmap(dpy, visinfo, p); ctx = piglit_get_glx_context(dpy, visinfo); glXMakeCurrent(dpy, g, ctx); piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); /* Clear to green */ glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /* Noop */ XSetErrorHandler(handler); glXSwapBuffers(dpy, p); /* We want to actually catch any X error that leaks through as * a result of glXSwapBuffers() before we go saying "pass" or * "fail". */ XSync(dpy, False); glXDestroyPixmap(dpy, g); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); return 0; }
int main(int argc, char **argv) { Display *display; XVisualInfo *visual; Window window; GLXContext ctx; void (*test_func)(Display*, GLXDrawable); parse_args(argc, argv, &test_func); display = piglit_get_glx_display(); visual = piglit_get_glx_visual(display); window = piglit_get_glx_window(display, visual); ctx = piglit_get_glx_context(display, visual); glXMakeCurrent(display, window, ctx); /* Must initialize static variables of this function. */ piglit_glx_get_error(display, NULL); test_func(display, window); return 0; }
void GLX_ARB_create_context_setup(void) { dpy = piglit_get_glx_display(); piglit_require_glx_version(dpy, 1, 4); piglit_require_glx_extension(dpy, "GLX_ARB_create_context"); __piglit_glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddress((const GLubyte *) "glXCreateContextAttribsARB"); assert(__piglit_glXCreateContextAttribsARB != NULL); visinfo = piglit_get_glx_visual(dpy); fbconfig = piglit_glx_get_fbconfig_for_visinfo(dpy, visinfo); win = piglit_get_glx_window_unmapped(dpy, visinfo); glxWin = glXCreateWindow(dpy, fbconfig, win, NULL); piglit_glx_get_error(dpy, NULL); old_handler = XSetErrorHandler(x_error_handler); }
int main(int argc, char **argv) { Pixmap p; GLXPixmap g; static const float green_alpha_zero[4] = {0.0, 1.0, 0.0, 0.0}; static const float green_alpha_one[4] = {0.0, 1.0, 0.0, 1.0}; GLXContext ctx; bool pass; GLint alpha_bits; dpy = XOpenDisplay(NULL); if (dpy == NULL) { fprintf(stderr, "couldn't open display\n"); piglit_report_result(PIGLIT_FAIL); } piglit_glx_get_error(dpy, NULL); piglit_require_glx_version(dpy, 1, 3); visinfo = piglit_get_glx_visual(dpy); p = XCreatePixmap(dpy, DefaultRootWindow(dpy), piglit_width, piglit_height, visinfo->depth); g = glXCreateGLXPixmap(dpy, visinfo, p); ctx = piglit_get_glx_context(dpy, visinfo); glXMakeCurrent(dpy, g, ctx); piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); /* Clear to green */ glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /* Noop */ glXSwapBuffers(dpy, g); /* We want to actually catch any X error that leaks through as * a result of glXSwapBuffers() before we go saying "pass" or * "fail". */ XSync(dpy, False); /* If the visual has no alpha, then the GL spec requires that 1.0 be * read back. Otherwise, we should read back the 0.0 that we wrote. */ glGetIntegerv(GL_ALPHA_BITS, &alpha_bits); if (alpha_bits == 0) { pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green_alpha_one); } else { pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green_alpha_zero); } glXDestroyPixmap(dpy, g); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); return 0; }
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); }