[Piglit] [PATCH] utils: Write event loop for Waffle+WGL

Jose Fonseca jfonseca at vmware.com
Wed Feb 25 03:04:08 PST 2015


On 23/02/15 21:00, Emil Velikov wrote:
> On 20 February 2015 at 23:38, Jose Fonseca <jfonseca at vmware.com> wrote:
>> Without this it is not really possible to see test rendering
>> interactively.
> I'm a bit low on experience wrt Windows input code, but this looks great afaict.
>
> Fwiw
> Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>


>> ---
>>   .../piglit-framework-gl/piglit_wgl_framework.c     | 72 +++++++++++++++++++---
>>   1 file 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 4df2eb6..1cce4b2 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);
> Just a question - some tests actually set the keyboard_func. Do those
> work under Windows ?

I confess I haven't tried them yet.  It should in theory -- the code is 
there.

But looking at tests/texturing/lodbias.c, I don't think the escape key 
will ever reach the key handler function, as it is intercepted. Maybe I 
should only handle the escape key when there is no user_keyboard_func . 
  That might be more helpful.

There's a power outage here affecting many of my development machines, 
so I can't try it now, but I'll give it a try when I can, and maybe 
polish things a bit in a follow on commmit.

>> +               }
>> +               winsys_fw->need_redisplay = true;
>> +               break;
>> +       case WM_CLOSE:
>> +               exit(0);
>> +       case WM_QUIT:
>> +               exit(0);
> As a future work we might want to clean/teardown things here (also in
> piglit_x11_framework), but until then this will do just fine.
> Feel free to add a comment if you have a second.

I'll add a comment to that effect.

>
> Thanks Jose!
>
> -Emil
>

Thanks for the review Emil.

Jose



More information about the Piglit mailing list