Game Development Reference
In-Depth Information
In C, the preceding code simply becomes the following:
glDisable(GL_DITHER);
glTexEnvx(GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE,GL_MODULATE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -3.0f);
glRotatef(mAngle, 0, 0, 1.0f);
glRotatef(mAngle*0.25f, 1, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
Cube_draw();
glRotatef(mAngle*2.0f, 0, 1, 1);
glTranslatef(0.5f, 0.5f, 0.5f);
Cube_draw();
mAngle += 1.2f;
Note that drawFrame() is defined as static , which tells the compiler that this function will be visible
only by functions within cuberenderer.c (a bit similar to the private keyword in Java). Furthermore, the
function Cube_draw() is implemented in cube.c .
Listing 5-12. Drawing Frames from cuberenderer.c
static void drawFrame()
{
/*
* By default, OpenGL enables features that improve quality
* but reduce performance. One might want to tweak that
* especially on software renderer.
*/
glDisable(GL_DITHER);
glTexEnvx(GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE,GL_MODULATE);
/*
* Usually, the first thing one might want to do is to clear
* the screen. The most efficient way of doing this is to use
* glClear().
*/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Search WWH ::




Custom Search