Advertisement

Lesson 10 Question: What is the Main Loop?

Started by June 21, 2014 01:53 AM
2 comments, last by Cydriic 10 years, 5 months ago

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.

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.

Advertisement

Thank You so Much, Understood! :)

This topic is closed to new replies.

Advertisement