Tuesday, August 1, 2017

Window Event Loop Processing

Month Four : Week One

This week I encountered an issue that my teammate Andre brought to me while he was trying to integrate GWindow into his first month code demo. His demo is a simple OpenGL rendering application,and this week he was working on the Win32 version of it. His window was being created just fine and OpenGL was successfully initializing on my GWindow window, however the window was accepting no user input. The cursor was stuck spooling, no window buttons could be pressed, and the keyboard input the window was supposed to be catching wasn't working at all. This was distressing because it worked fine in the test suite, and I couldn't figure out why the window wasn't handling its event loop.


Eventually I remembered the issue I had working with Linux and Mac OSX's event loop, and how I had to manually process all messages in the loop after important operations to flush the event queue and continue the program. I decided to add a new function to the GWindow interface, ProcessWindowEvents. This cross-platform function will read in and handle all queued messages in any platform's event loop and then break and continue. The user will call this function once per "frame" of their program, probably along with the main game loop. The demo app is working just fine now and my library is better because of solving this issue.

No comments:

Post a Comment