2 * Copyright 2011 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Adam Jackson <ajax@redhat.com>
28 /** @file glx-pixmap-crosscheck.c
30 * There are three ways to create a GLXPixmap, depending on the GLX version
31 * and extensions, and two ways to destroy them. The spec says you should
32 * use the matching destructor for a given constructor, but does not say
33 * what to expect if you aren't that fastidious.
36 #include "piglit-util-gl.h"
37 #include "piglit-glx-util.h"
39 int piglit_width
= 50, piglit_height
= 50;
41 static XVisualInfo
*visinfo
;
43 int result
= PIGLIT_PASS
;
46 expect_no_error(Display
*dpy
, XErrorEvent
*err
)
49 * Just warn if errors happen, since we're testing something that's
50 * not guaranteed to work. All we're really looking for here is
57 typedef GLXPixmap (*pfn_create_pixmap
)(Display
*, GLXFBConfigSGIX
, Pixmap
);
60 main(int argc
, char **argv
)
62 const char *extensions
;
66 pfn_create_pixmap create_pixmap_with_config
= NULL
;
68 dpy
= XOpenDisplay(NULL
);
70 fprintf(stderr
, "couldn't open display\n");
71 piglit_report_result(PIGLIT_FAIL
);
74 piglit_glx_get_error(dpy
, NULL
);
75 piglit_require_glx_version(dpy
, 1, 3);
77 visinfo
= piglit_get_glx_visual(dpy
);
78 fbc
= piglit_glx_get_fbconfig_for_visinfo(dpy
, visinfo
);
79 p
= XCreatePixmap(dpy
, DefaultRootWindow(dpy
), piglit_width
,
80 piglit_height
, visinfo
->depth
);
82 extensions
= glXQueryExtensionsString(dpy
, DefaultScreen(dpy
));
83 if (strstr(extensions
, "GLX_SGIX_fbconfig")) {
84 const GLubyte entrypoint
[] = "glXCreateGLXPixmapWithConfigSGIX";
85 create_pixmap_with_config
=
86 (pfn_create_pixmap
)glXGetProcAddressARB(entrypoint
);
89 XSetErrorHandler(expect_no_error
);
91 /* pre-1.3 ctor, 1.3 dtor */
92 g
= glXCreateGLXPixmap(dpy
, visinfo
, p
);
93 glXDestroyPixmap(dpy
, g
);
96 /* extension ctor, 1.3 dtor */
97 if (create_pixmap_with_config
) {
98 g
= create_pixmap_with_config(dpy
, fbc
, p
);
99 glXDestroyPixmap(dpy
, g
);
103 /* 1.3 ctor, 1.2 dtor */
104 g
= glXCreatePixmap(dpy
, fbc
, p
, NULL
);
105 glXDestroyGLXPixmap(dpy
, g
);
108 piglit_report_result(result
);