Jump to content
  • Advertisement
Sign in to follow this  

Lesson 10 Question: What is the Main Loop?

This topic is 1642 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone,


I'm done with Lesson 10, but there is something I don't understand.


Where is the Main Loop in the Code? Where does it start and end?


I know the program ends if anything returns FALSE, but I just don't see where the Loop is Located.


We initialize the Texture system and we setup the world by reading the World File, we also Initialize OpenGL and Create the Window.


I guess those previous functions are only ran once...


Then we have three functions, we Draw our Scene and then we read and deal with the Windows Events. Are these the Loops? If so what determines that?




Thanks guys. Love the Tutorials.

Edited by Cydriic

Share this post

Link to post
Share on other sites

Normally, a C or C++ program enters a function called 'int main(int argc, char *argv[])' or WinMain(...), or equivalent. That special function is known as the "entrypoint" and is where control is first passed to your program. When that main function returns, then your program ends.


The "main loop" is a concept - the idea that things like games loop around continually until they are ready to exit. When they are ready, they end the loop and let the main() function return. This loop doesn't have to be an actual for() or while() loop, though it often is.


Sometimes, when using certain game engines or certain graphical or GUI libraries, the libraries or engines handle the loop for you behind the scenes.


The NEHE tutorials (which are very outdated - I've heard this is a better tutorial, but can't personally comment on it), use Win32 (Microsoft Window's API), so the entry point function is called WinMain(), and is semi-explained in NEHE tutorial 1.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!