Game Development Reference
In-Depth Information
glutCreateWindow
The
glutCreateWindow
function spawns a top-level window for the Windows OS
to manage, and sets the title we want it to display in the title bar.
glutSetOption
The
glutSetOption
function is used to configure a number of options in the win-
dow, even the values that we've already edited such as the display mode and the
window size. The two options passed in the previous example ensure that when the
main window is closed, the main loop will return, exiting our game logic. The main
loop itself will be explained in the following section.
Launching FreeGLUT
The final and possibly most important function in FreeGLUT is
glutMainloop()
.
The moment this function is called, we hand the responsibility of application man-
agement over to the FreeGLUT library. From that point forward, we only have control
when FreeGLUT calls the callback functions we mapped previously.
In our project code, all of the listed functions are encapsulated with a global function
called
glutmain()
, which accepts an instance of our application class as a para-
meter, stores it in our global pointer, calls its own
Initialize()
function (because
even our application class will want to know when the application is powering up),
and then calls the
glutMainloop()
function.
And so, finally, we have everything in place to write the all-powerful
main()
function.
In this chapter's source code, the
main()
function looks as follows:
int main(int argc, char** argv)
{
BulletOpenGLApplication demo;
return glutmain(argc, argv, 1024, 768,
"Introduction to Game Physics with Bullet
Physics and OpenGL", &demo);
}
Search WWH ::
Custom Search