2 * Copyright 2011 Red Hat, Inc.
3 * Copyright 2011 Intel Corporation.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 /** @file glx-swap-pixmap-bad.c
27 * Test that glXSwapbuffer() on a non-GLXDrawable throws GLXBadDrawable.
29 * From the GLX 1.4 specification page 34 (page 40 of the PDF):
31 * If draw is not a valid GLX drawable, glXSwapBuffers generates a
32 * GLXBadDrawable error.
35 #include "piglit-util-gl.h"
36 #include "piglit-glx-util.h"
38 int piglit_width
= 50, piglit_height
= 50;
40 static XVisualInfo
*visinfo
;
45 handler(Display
*dpy
, XErrorEvent
*err
)
47 if (piglit_glx_get_error(dpy
, err
) != GLXBadDrawable
)
53 main(int argc
, char **argv
)
59 dpy
= XOpenDisplay(NULL
);
61 fprintf(stderr
, "couldn't open display\n");
62 piglit_report_result(PIGLIT_FAIL
);
65 piglit_glx_get_error(dpy
, NULL
);
66 piglit_require_glx_version(dpy
, 1, 3);
68 visinfo
= piglit_get_glx_visual(dpy
);
69 p
= XCreatePixmap(dpy
, DefaultRootWindow(dpy
), piglit_width
,
70 piglit_height
, visinfo
->depth
);
72 g
= glXCreateGLXPixmap(dpy
, visinfo
, p
);
74 ctx
= piglit_get_glx_context(dpy
, visinfo
);
75 glXMakeCurrent(dpy
, g
, ctx
);
76 piglit_dispatch_default_init(PIGLIT_DISPATCH_GL
);
79 glClearColor(0.0, 1.0, 0.0, 0.0);
80 glClear(GL_COLOR_BUFFER_BIT
);
83 XSetErrorHandler(handler
);
84 glXSwapBuffers(dpy
, p
);
86 /* We want to actually catch any X error that leaks through as
87 * a result of glXSwapBuffers() before we go saying "pass" or
92 glXDestroyPixmap(dpy
, g
);
94 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);