Пример #1
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;
}
Пример #2
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);
}
Пример #3
0
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;
}