framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / wgl / wgl-multi-window-single-context.c
blob3c801be92046d24a2ee93010140b59b9b2ccc4d0
1 /*
2 * Copyright © 2017 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
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.
25 * Test rendering into multiple windows with one context.
27 * Authors:
28 * Brian Paul
31 #include <assert.h>
32 #include <stdio.h>
33 #include "piglit-util-gl.h"
34 #include "piglit-wgl-util.h"
37 #define MAX_WINDOWS 8
39 static HWND win[MAX_WINDOWS];
40 static int num_windows = MAX_WINDOWS;
41 static HGLRC ctx;
43 static const float colors[MAX_WINDOWS][4] = {
44 {1, 0, 0, 1},
45 {0, 1, 0, 1},
46 {0, 0, 1, 1},
47 {0, 1, 1, 1},
48 {1, 0, 1, 1},
49 {1, 1, 0, 1},
50 {1, 1, 1, 1},
51 {.5, .5, .5, 1},
55 enum piglit_result
56 draw(void)
58 int i;
59 bool pass = true;
61 /* draw colored quad in each window */
62 for (i = 0; i < num_windows; i++) {
63 wglMakeCurrent(GetDC(win[i]), ctx);
65 glClear(GL_COLOR_BUFFER_BIT);
66 glColor4fv(colors[i]);
67 piglit_draw_rect(-1, -1, 2, 2);
70 /* probe windows */
71 for (i = 0; i < num_windows; i++) {
72 wglMakeCurrent(GetDC(win[i]), ctx);
74 glReadBuffer(GL_BACK);
75 /* only read back 20x20 region instead of
76 * piglit_width x piglit_height since Windows may
77 * resize our windows.
79 int p = piglit_probe_rect_rgb(0, 0, 20, 20,
80 colors[i]);
82 SwapBuffers(GetDC(win[i]));
84 if (!p) {
85 printf("Failed probe in window %d\n", i);
86 pass = false;
90 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
94 int
95 main(int argc, char **argv)
97 int i;
99 piglit_width = 100;
100 piglit_height = 100;
102 for (i = 1; i < argc; i++) {
103 if (strcmp(argv[i], "-auto") == 0) {
104 piglit_automatic = 1;
105 break;
109 /* Create windows */
110 for (i = 0; i < num_windows; i++) {
111 win[i] = piglit_get_wgl_window();
112 MoveWindow(win[i], i*130, 0,
113 piglit_width, piglit_height, FALSE);
114 assert(win[i]);
117 ctx = piglit_get_wgl_context(win[0]);
118 assert(ctx);
120 if (!wglMakeCurrent(GetDC(win[0]), ctx)) {
121 fprintf(stderr, "wglMakeCurrent failed\n");
122 return 0;
125 piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
127 piglit_wgl_event_loop(draw);
129 return 0;