You normally do this with an in projection mode, not adjusting the Z-value so that its fitting the screen.
Projection mode uses the Z-value only for sorting, and not for the actual depth in the scene. So ideal for 2D drawing.
You can easily switch between the modes from gl, and mix 2d with 3d graphics.
http://wiki.delphigl.com/index.php/Tutorial_2D here is an very good tutorial which describes the modes, it's normal opengl for desktop, so there are statements that doesn't exist in opengl es, which android does use, but you can understand whats going on there.
- Code: Select all
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(0, width, height, 0, -1, 1);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}
This is some initialization code for the projection matrix using the native screen resolution (480x320 on the G1)
If you want that your game looks the same on every device you need to scale manually, or set glViewport to an fixed resolution and gl scales for you. (ignoring the aspect ratio)
For more code you can look at the andengine, or simply use it.
Edit: aaargh i now see that the tutorial is in german, forgot this, sorry

. Well i you are german than it's probably better for you, if not, well there are a million tutorials on the net
