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
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 rendering into multiple windows with one context.
33 #include "piglit-util-gl.h"
34 #include "piglit-wgl-util.h"
39 static HWND win
[MAX_WINDOWS
];
40 static int num_windows
= MAX_WINDOWS
;
43 static const float colors
[MAX_WINDOWS
][4] = {
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);
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
79 int p
= piglit_probe_rect_rgb(0, 0, 20, 20,
82 SwapBuffers(GetDC(win
[i
]));
85 printf("Failed probe in window %d\n", i
);
90 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
95 main(int argc
, char **argv
)
102 for (i
= 1; i
< argc
; i
++) {
103 if (strcmp(argv
[i
], "-auto") == 0) {
104 piglit_automatic
= 1;
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
);
117 ctx
= piglit_get_wgl_context(win
[0]);
120 if (!wglMakeCurrent(GetDC(win
[0]), ctx
)) {
121 fprintf(stderr
, "wglMakeCurrent failed\n");
125 piglit_dispatch_default_init(PIGLIT_DISPATCH_GL
);
127 piglit_wgl_event_loop(draw
);