Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
OpenGL Game Development By Example

You're reading from   OpenGL Game Development By Example Design and code your own 2D and 3D games efficiently using OpenGL and C++

Arrow left icon
Product type Paperback
Published in Mar 2016
Publisher
ISBN-13 9781783288199
Length 340 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Robert Madsen Robert Madsen
Author Profile Icon Robert Madsen
Robert Madsen
Stephen Madsen Stephen Madsen
Author Profile Icon Stephen Madsen
Stephen Madsen
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

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 program that we want it to listen to events. Open RoboRacer.cpp and locate the WndProc function. WndProc is part of the code that was created for us when use used the Win32 Project template to start our game. WndProc is known as a callback function...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime