2 * Copyright © 2014 Emil Velikov
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
28 #include "piglit-util-gl.h"
29 #include "piglit_wl_framework.h"
32 process_next_event(struct piglit_winsys_framework
*winsys_fw
)
34 const struct piglit_gl_test_config
*test_config
= winsys_fw
->wfl_fw
.gl_fw
.test_config
;
39 bRet
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
43 fprintf(stderr
, "message = 0x%04x, wParam = 0x%04x\n", msg
.message
, msg
.wParam
);
46 switch (msg
.message
) {
48 winsys_fw
->need_redisplay
= true;
51 if (winsys_fw
->user_reshape_func
) {
53 if (GetClientRect(msg
.hwnd
, &rect
)) {
54 int width
= rect
.right
- rect
.left
;
55 int height
= rect
.bottom
- rect
.top
;
56 winsys_fw
->user_reshape_func(width
, height
);
59 winsys_fw
->need_redisplay
= true;
62 if (winsys_fw
->user_keyboard_func
) {
63 winsys_fw
->user_keyboard_func(msg
.wParam
, 0, 0);
65 winsys_fw
->need_redisplay
= true;
68 if (msg
.wParam
== SC_CLOSE
) {
69 PostQuitMessage(EXIT_SUCCESS
);
73 /* XXX: we never see this message here in practice, only WM_SYSCOMMAND::SC_CLOSE above */
74 PostQuitMessage(EXIT_SUCCESS
);
77 /* TODO: cleanup/teardown things */
83 TranslateMessage(&msg
);
84 DispatchMessage(&msg
);
87 if (winsys_fw
->need_redisplay
) {
88 enum piglit_result result
= PIGLIT_PASS
;
89 if (test_config
->display
)
90 result
= test_config
->display();
92 piglit_report_result(result
);
93 winsys_fw
->need_redisplay
= false;
98 enter_event_loop(struct piglit_winsys_framework
*winsys_fw
)
101 process_next_event(winsys_fw
);
105 show_window(struct piglit_winsys_framework
*winsys_fw
)
107 waffle_window_show(winsys_fw
->wfl_fw
.window
);
111 destroy(struct piglit_gl_framework
*gl_fw
)
113 struct piglit_winsys_framework
*winsys_fw
= piglit_winsys_framework(gl_fw
);
115 if (winsys_fw
== NULL
)
118 piglit_winsys_framework_teardown(winsys_fw
);
122 struct piglit_gl_framework
*
123 piglit_wgl_framework_create(const struct piglit_gl_test_config
*test_config
)
125 struct piglit_winsys_framework
*winsys_fw
= NULL
;
126 struct piglit_gl_framework
*gl_fw
= NULL
;
129 winsys_fw
= calloc(1, sizeof(*winsys_fw
));
130 gl_fw
= &winsys_fw
->wfl_fw
.gl_fw
;
132 ok
= piglit_winsys_framework_init(winsys_fw
, test_config
,
133 WAFFLE_PLATFORM_WGL
);
137 winsys_fw
->show_window
= show_window
;
138 winsys_fw
->enter_event_loop
= enter_event_loop
;
139 gl_fw
->destroy
= destroy
;
141 winsys_fw
->need_redisplay
= true;