Add a negative test for bitwise not used in a larger expression.
[piglit/hramrach.git] / tests / glx / glx-swap-exchange.c
blob228a6d316df0d46b9e316a83fa34017a3f26f685
1 /*
2 * Copyright © 2010 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.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /** @file glx-swap-exchange.c
30 * Test that GLX_SWAP_EXCHANGE_OML does in fact cause the back buffer to get
31 * exchanged on swap.
34 #include "piglit-util.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 GLboolean pass = GL_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);
52 /* Clear background to gray */
53 glClearColor(0.0, 1.0, 0.0, 0.0);
54 glClear(GL_COLOR_BUFFER_BIT);
55 glXSwapBuffers(dpy, win);
56 glClearColor(1.0, 0.0, 0.0, 0.0);
57 glClear(GL_COLOR_BUFFER_BIT);
58 glXSwapBuffers(dpy, win);
60 pass = piglit_probe_pixel_rgba(0, 0, green);
62 glXSwapBuffers(dpy, win);
64 return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
68 XVisualInfo *
69 piglit_get_swap_exchange_visual(Display *dpy)
71 XVisualInfo *visinfo;
72 int attrib[] = {
73 GLX_RGBA,
74 GLX_RED_SIZE, 1,
75 GLX_GREEN_SIZE, 1,
76 GLX_BLUE_SIZE, 1,
77 GLX_DOUBLEBUFFER,
78 GLX_SWAP_METHOD_OML, GLX_SWAP_EXCHANGE_OML,
79 None
81 int screen = DefaultScreen(dpy);
83 visinfo = glXChooseVisual(dpy, screen, attrib);
84 if (visinfo == NULL) {
85 fprintf(stderr,
86 "Couldn't get a GLX_SWAP_EXCHANGE_OML, RGBA, "
87 "double-buffered visual\n");
88 piglit_report_result(PIGLIT_SKIP);
89 exit(1);
92 return visinfo;
95 int
96 main(int argc, char **argv)
98 int i;
99 const char *glx_extension_list;
101 for(i = 1; i < argc; ++i) {
102 if (!strcmp(argv[i], "-auto"))
103 piglit_automatic = 1;
104 else
105 fprintf(stderr, "Unknown option: %s\n", argv[i]);
108 dpy = XOpenDisplay(NULL);
109 if (dpy == NULL) {
110 fprintf(stderr, "couldn't open display\n");
111 piglit_report_result(PIGLIT_FAILURE);
114 glx_extension_list = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
115 if (strstr(glx_extension_list, "GLX_OML_swap_method") == NULL) {
116 printf("Requires GLX_OML_swap_method\n");
117 piglit_report_result(PIGLIT_SKIP);
120 visinfo = piglit_get_swap_exchange_visual(dpy);
121 win = piglit_get_glx_window(dpy, visinfo);
123 XMapWindow(dpy, win);
125 piglit_glx_event_loop(dpy, draw);
127 return 0;