Game Development Reference
In-Depth Information
texture = new Texture((GLGame)game, "bobrgb888.png");
}
@Override
public void present( float deltaTime) {
GL10 gl = glGraphics.getGL();
gl.glViewport(0, 0, glGraphics.getWidth(), glGraphics.getHeight());
gl.glClear(GL10. GL_COLOR_BUFFER_BIT );
gl.glMatrixMode(GL10. GL_PROJECTION );
gl.glLoadIdentity();
gl.glOrthof(0, 320, 0, 480, 1, -1);
gl.glEnable(GL10. GL_TEXTURE_2D );
texture.bind();
gl.glEnableClientState(GL10. GL_TEXTURE_COORD_ARRAY );
gl.glEnableClientState(GL10. GL_VERTEX_ARRAY );
vertices.position(0);
gl.glVertexPointer(2, GL10. GL_FLOAT , VERTEX_SIZE, vertices);
vertices.position(2);
gl.glTexCoordPointer(2, GL10. GL_FLOAT , VERTEX_SIZE, vertices);
gl.glDrawElements(GL10. GL_TRIANGLES , 6, GL10. GL_UNSIGNED_SHORT , indices);
}
Note the use of our awesome Texture class, which brings down the code size considerably.
Figure 7-15 shows the output, and Bob in all his glory.
Figure 7-15. Bob, indexed
Search WWH ::




Custom Search