Game Development Reference
In-Depth Information
bobTexture.reload();
gl.glEnable(GL10. GL_TEXTURE_2D );
bobTexture.bind();
}
@Override
public void present( float deltaTime) {
GL10 gl = glGraphics.getGL();
gl.glClear(GL10. GL_COLOR_BUFFER_BIT );
gl.glMatrixMode(GL10. GL_MODELVIEW );
for ( int i = 0; i < NUM_BOBS ; i++) {
gl.glLoadIdentity();
gl.glTranslatef(bobs[i].x, bobs[i].y, 0);
gl.glRotatef(45, 0, 0, 1);
gl.glScalef(2, 0.5f, 0);
bobModel.draw(GL10. GL_TRIANGLES , 0, 6);
}
fpsCounter.logFrame();
}
Running this “improved� version gives the following performance on the three devices:
Hero:
12-10 04:41:56.750: DEBUG/FPSCounter(467): fps: 23
12-10 04:41:57.770: DEBUG/FPSCounter(467): fps: 23
12-10 04:41:58.500: DEBUG/dalvikvm(467): GC freed 21821 objects / 524288 bytes in 133ms
12-10 04:41:58.790: DEBUG/FPSCounter(467): fps: 19
12-10 04:41:59.830: DEBUG/FPSCounter(467): fps: 23
Droid:
12-10 04:45:26.906: DEBUG/FPSCounter(9116): fps: 39
12-10 04:45:27.914: DEBUG/FPSCounter(9116): fps: 41
12-10 04:45:28.922: DEBUG/FPSCounter(9116): fps: 41
12-10 04:45:29.937: DEBUG/FPSCounter(9116): fps: 40
Nexus One:
12-10 04:37:46.097: DEBUG/FPSCounter(2168): fps: 43
12-10 04:37:47.127: DEBUG/FPSCounter(2168): fps: 45
12-10 04:37:48.147: DEBUG/FPSCounter(2168): fps: 44
12-10 04:37:49.157: DEBUG/FPSCounter(2168): fps: 44
12-10 04:37:50.167: DEBUG/FPSCounter(2168): fps: 44
As you can see, all of the devices have already benefited a tiny bit from our optimizations.
Of course, the effects are not exactly huge. This can be attributed to the fact that when we
originally called all those methods at the beginning of the frame, there were no triangles in
the pipeline.
Search WWH ::




Custom Search