ext_transform_feedback: document missing mode in usage
[piglit.git] / tests / glx / glx-swap-singlebuffer.c
blob2cf2f70d3bf63da1e71c9c68e8e4b3549a4c01e0
1 /*
2 * Copyright © 2011 Intel Corporation
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
13 * Software.
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
21 * IN THE SOFTWARE.
24 /** @file glx-swap-singlebuffer.c
26 * Test that glXSwapbuffer() on a single-buffered FBConfig is a noop.
28 * From the GLX 1.4 specification page 34 (page 40 of the PDF):
30 * This operation is a no-op if draw was created with a
31 * non-double-buffered GLXFBConfig, or if draw is a GLXPixmap.
34 #include "piglit-util-gl.h"
35 #include "piglit-glx-util.h"
37 int piglit_width = 50, piglit_height = 50;
38 static Display *dpy;
39 static Window win;
40 static XVisualInfo *visinfo;
42 enum piglit_result
43 draw(Display *dpy)
45 bool pass = true;
46 float green[] = {0.0, 1.0, 0.0, 0.0};
47 GLXContext ctx;
49 ctx = piglit_get_glx_context(dpy, visinfo);
50 glXMakeCurrent(dpy, win, ctx);
51 piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
53 /* Clear to green */
54 glClearColor(0.0, 1.0, 0.0, 0.0);
55 glClear(GL_COLOR_BUFFER_BIT);
57 /* Noop */
58 glXSwapBuffers(dpy, win);
60 /* We want to actually catch any X error that leaks through as
61 * a result of glXSwapBuffers() before we go saying "pass" or
62 * "fail".
64 XSync(dpy, False);
66 pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green);
68 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
71 XVisualInfo *
72 get_single_buffer_visual(Display *dpy)
74 XVisualInfo *visinfo;
75 int attrib[] = {
76 GLX_RGBA,
77 GLX_RED_SIZE, 1,
78 GLX_GREEN_SIZE, 1,
79 GLX_BLUE_SIZE, 1,
80 GLX_ALPHA_SIZE, 1,
81 None
83 int screen = DefaultScreen(dpy);
85 visinfo = glXChooseVisual(dpy, screen, attrib);
86 if (visinfo == NULL) {
87 fprintf(stderr,
88 "Couldn't get a single buffered, RGBA visual\n");
89 piglit_report_result(PIGLIT_SKIP);
92 return visinfo;
95 int
96 main(int argc, char **argv)
98 int i;
100 for(i = 1; i < argc; ++i) {
101 if (!strcmp(argv[i], "-auto"))
102 piglit_automatic = 1;
103 else
104 fprintf(stderr, "Unknown option: %s\n", argv[i]);
107 dpy = XOpenDisplay(NULL);
108 if (dpy == NULL) {
109 fprintf(stderr, "couldn't open display\n");
110 piglit_report_result(PIGLIT_FAIL);
113 visinfo = get_single_buffer_visual(dpy);
114 win = piglit_get_glx_window(dpy, visinfo);
116 piglit_glx_event_loop(dpy, draw);
118 return 0;