Game Development Reference
In-Depth Information
Tip
Note that we have already enabled this feature back in
Chapter 1
,
Building a
Game Application
, when we called the
glutInitDisplayMode()
function.
The following diagram shows the working of double-buffering:
The command to swap these buffers in FreeGLUT is
glutSwapBuffers()
, and
the command to clear the backbuffer is
glClear()
. In order to clear the color value
of every pixel in the current buffer, we pass the value
GL_COLOR_BUFFER_BIT
into
glClear()
. Both of these functions must be called inside the
Idle()
function,
which is automatically and repeatedly called by FreeGLUT whenever it's not busy
processing its own events. This is the moment where we should process our own
background tasks such as physics processing, object management, responding to
game events, and even rendering itself.
Search WWH ::
Custom Search