diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2015-02-20 23:38:14 +0000 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2015-02-25 11:04:00 +0000 |
commit | 10d692dfbe0d1cab7c63116169402f2862e2c869 (patch) | |
tree | 98ac80bc2727e9de12bc9b86b7cbf0f5c0b16d79 /tests/util | |
parent | 1a40d62470653bc56a2ab1b9bb56538fd2d0bcc8 (diff) |
utils: Write event loop for Waffle+WGL.
Without this it is not really possible to see test rendering
interactively.
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'tests/util')
-rw-r--r-- | tests/util/piglit-framework-gl/piglit_wgl_framework.c | 72 |
1 files changed, 64 insertions, 8 deletions
diff --git a/tests/util/piglit-framework-gl/piglit_wgl_framework.c b/tests/util/piglit-framework-gl/piglit_wgl_framework.c index 4df2eb69d..e9fd01ccb 100644 --- a/tests/util/piglit-framework-gl/piglit_wgl_framework.c +++ b/tests/util/piglit-framework-gl/piglit_wgl_framework.c @@ -29,16 +29,72 @@ #include "piglit_wl_framework.h" static void -enter_event_loop(struct piglit_winsys_framework *winsys_fw) +process_next_event(struct piglit_winsys_framework *winsys_fw) { + const struct piglit_gl_test_config *test_config = winsys_fw->wfl_fw.gl_fw.test_config; + + BOOL bRet; + MSG msg; + + bRet = GetMessage(&msg, NULL, 0, 0 ); + if (bRet <= 0) { + return; + } + + switch (msg.message) { + case WM_PAINT: + winsys_fw->need_redisplay = true; + break; + case WM_SIZE: + if (winsys_fw->user_reshape_func) { + RECT rect; + if (GetClientRect(msg.hwnd, &rect)) { + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + winsys_fw->user_reshape_func(width, height); + } + } + winsys_fw->need_redisplay = true; + break; + case WM_KEYDOWN: + switch (msg.wParam) { + case VK_ESCAPE: + PostMessage(msg.hwnd, WM_CLOSE, 0, 0); + break; + } + break; + case WM_CHAR: + if (winsys_fw->user_keyboard_func) { + winsys_fw->user_keyboard_func(msg.wParam, 0, 0); + } + winsys_fw->need_redisplay = true; + break; + case WM_CLOSE: + case WM_QUIT: + /* TODO: cleanup/teardown things */ + exit(0); + default: + break; + } + + TranslateMessage(&msg); + DispatchMessage(&msg); - /* FINISHME: Write event loop for Windows. - * - * Until we have proper Windows/WGL support, give the user enough - * time to view the window by sleeping. - */ - fprintf(stderr, "Press any key when done.\n"); - getchar(); + if (winsys_fw->need_redisplay) { + enum piglit_result result = PIGLIT_PASS; + if (test_config->display) + result = test_config->display(); + if (piglit_automatic) + piglit_report_result(result); + winsys_fw->need_redisplay = false; + } +} + +static void +enter_event_loop(struct piglit_winsys_framework *winsys_fw) +{ + while (true) + process_next_event(winsys_fw); } static void |