2 * Copyright (c) 2011, VMware, 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
25 * Test framebuffer binding state across glXMakeCurrent calls.
30 #include "piglit-util-gl.h"
31 #include "piglit-glx-util.h"
33 int piglit_width
= 50, piglit_height
= 50;
34 static const char *TestName
= "glx-fbo-binding";
36 static Window Windows
[2];
37 static GLXContext ctx
;
46 /* bind first window, create FBO, bind it */
47 glXMakeCurrent(dpy
, Windows
[0], ctx
);
48 glGenFramebuffersEXT(1, &fbo
);
50 printf("%s: glGenFramebuffer() failed (%u)\n",
54 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT
, fbo
);
55 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT
, &b
);
57 printf("%s: glBindFramebuffer() #1 failed (%u vs %d)\n",
62 /* bind second window, test FBO binding (should be unchanged) */
63 glXMakeCurrent(dpy
, Windows
[1], ctx
);
64 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT
, &b
);
66 printf("%s: glBindFramebuffer() #2 failed (%u vs %d)\n",
71 /* bind second window again, test FBO binding */
72 glXMakeCurrent(dpy
, Windows
[1], ctx
);
73 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT
, &b
);
75 printf("%s: glBindFramebuffer() #3 failed (%u vs %d)\n",
85 main(int argc
, char **argv
)
91 for (i
= 1; i
< argc
; i
++) {
92 if (strcmp(argv
[i
], "-auto") == 0) {
98 dpy
= XOpenDisplay(NULL
);
100 fprintf(stderr
, "Failed to open display\n");
101 piglit_report_result(PIGLIT_FAIL
);
104 visinfo
= piglit_get_glx_visual(dpy
);
105 Windows
[0] = piglit_get_glx_window(dpy
, visinfo
);
106 Windows
[1] = piglit_get_glx_window(dpy
, visinfo
);
108 ctx
= piglit_get_glx_context(dpy
, visinfo
);
110 glXMakeCurrent(dpy
, Windows
[0], ctx
);
111 piglit_dispatch_default_init(PIGLIT_DISPATCH_GL
);
113 piglit_glx_event_loop(dpy
, draw
);