Someone is listening

Now, it's time to actually write some code to implement input for our game. It turns out that some rudimentary input has already been implemented. This is because Windows is an event driven operating system and is already looking for input to occur. From a simplistic point of view, the main task of Windows (or any modern operating system) is to listen for events, and then do something based on those events.

So, whenever you hit a key on your keyboard, an event is triggered that wakes up Windows and says, "Hey, someone hit the keyboard!" Windows then passes that information to any programs that happen to be listening to keyboard events. The same occurs when you use the mouse.

The WndProc event listener

We have already told our ...

Get OpenGL Game Development By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.