Advertisement

WindowsProc and WinMain

Started by January 19, 2003 03:32 PM
2 comments, last by gatekeeper_prod 21 years, 9 months ago
Just a simple question regarding directX apps. Are the WindowsProc and WinMain going to loook virtually the same for most games? For all of the samples I have seen so far, the WindowsProc is the same, and WinMain has some miniscule differences. If they do change considerably, at what point or at what project size does this happen?
gatekeeper_prodwww.gatekeeperproductions.com
If you are wondering what the difference between the window procedure (WndProc()) and the main() function (WinMain()), they are two very different functions. The main() function tells the program what it will do. Simple as that. In main() you call all the functions. The window procedure tells Windows what it should do when the user inputs to the program, such as a key press, a mouse click, or a mouse move.
When you go homeTell them of us, and say:For your tomorrow,We gave our today.
Advertisement
That stuff, I already knew. what i was wondering was if the procedures, one or both, grew larger and more complex as an entire game project got larger. Or is it perhaps that the winproc and winmain stayed the same and just the gamemain grew. that was my question.

gatekeeper_prod
www.gatekeeperproductions.com
gatekeeper_prodwww.gatekeeperproductions.com
WinProc and WinMain are required by a windows application. You have to have your entry point, WinMain, and every window requires a message callback, WinProc.

If you''re writing a typical windows app, or a tool, then WinProc especially will require additional code to handle all the button clicks and window repainting.

For games, however, there''s no need to expand these routines. It''s usual practice to keep all your game code, initialisation, logic, etc. in seperate functions or classes and place the bare minimum in WinMain. A psuedocode example:

WinMain()
{
Initialise window stuff

Call InitialiseGame();

Windows message loop:
{
Process default windows messages (quit, for example)
Call RunGameFrame();
}

return 0;
}

This topic is closed to new replies.

Advertisement