Game Development Reference
In-Depth Information
After we instantiate msg , we enter into an endless loop. We first call
the API function PeekMessage , which checks the message queue for a
message. See MSDN for the argument descriptions. If there is a mes-
sage, it returns true and we handle the message. If PeekMessage
returns false, then we handle our own specific game code.
Summary
To use Direct3D, we must create a Windows application that has a
main window onto which we can render our 3D scenes. Further-
more, for games we create a special message loop that checks for
messages, and if there are messages, it processes them; otherwise
it executes our game logic.
Several Windows applications can be running concurrently; there-
fore Windows must manage resources between them and direct
messages to the applications that they were intended for. Messages
are sent to an application's message queue when an event
(keypress, mouse click, timer, etc.) has occurred for that
application.
Every Windows application has a message queue where the mes-
sages that an application receives are stored. The application's
message loop constantly checks the queue for messages and dis-
patches them to their intended window procedure. Note that a sin-
gle application can have several windows within it.
The window procedure is a special callback function we implement
that Windows calls when a window in our application receives a
message. In the window procedure, we write the code that we want
to be executed when a window in our application receives a partic-
ular message. Messages that we do not specifically handle are for-
warded to a default window procedure for default handling.
Search WWH ::




Custom Search