Archived

This topic is now archived and is closed to further replies.

gatekeeper_prod

WindowsProc and WinMain

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites