Game Development Reference
In-Depth Information
* probably based on features of this particular context
*/
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST);
glClearColor(.5f, .5f, .5f, 1);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
}
Drawing Frames
Drawing the actual frames is performed by the drawFrame() function. This function performs the
following steps:
It clears the screen via glClear() .
It sets the framework to draw 3D objects via the glMatrixMode(GL_MODELVIEW)
system call.
It performs an initial translation—a rotation to be applied to the first cube.
It draws the first cube by calling Cube_draw() . Note that vertices and colors must
be enabled via glEnableClientState() .
It performs a second rotation/translation and draws a second cube by calling
Cube_draw() again.
It increases the angle for the next interaction.
drawFrame() is meant to mirror the Java method CubeRenderer.drawFrame() , which includes the code
in the next fragment:
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0, 0, -3.0f);
gl.glRotatef(mAngle, 0, 1, 0);
gl.glRotatef(mAngle*0.25f, 1, 0, 0);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
mCube.draw(gl);
gl.glRotatef(mAngle*2.0f, 0, 1, 1);
gl.glTranslatef(0.5f, 0.5f, 0.5f);
mCube.draw(gl);
mAngle += 1.2f;
Search WWH ::




Custom Search