I am doing a little experiment with OpenGL ES on Nexus One. Got a problem about the full screen resolution. It seems like I can never get the real full resolution of Nexus One, which is 480*800. I am using an orthogonal projection and just want to draw a simple triangle with identity model view matrix:
@Override
public void sizeChanged(GL10 gl, int width, int height) {
/*
* Set our projection matrix. This doesn't have to be done
* each time we draw, but usually a new projection needs to
* be set when the viewport is resized.
*/
gl.glViewport( 0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluOrtho2D(gl, 0, width, 0, height);
}
The coordinates for the triangle are:
float[] coords = {
// X, Y, Z
0.0f, 0.0f, 0,
200.0f, 200.0f, 0,
100.0f, 0.0f, 0,
};
And I get the result below:
This result is same on emulator (480*800 res) and Nexus 1. Obviously I didn’t get the full resolution (because the top vertex of the triangle is already close to the right edge, if width is real 480, this should be on the left of the half width). Another strangeness is that in sizeChanged (I am using GLSurfaceView, this is the override method in the renderer required by GLSurfaceView), I always get width = 480 and height = 800 no matter whether I start the app in full screen mode. I was expecting that with app title bar and status bar, the size passed to sizeChanged should be smaller right? I mean if the size passed to this method isn’t the real size I am getting, then how can I setup a correct viewport?
I also did a quick implementation using GLUT on Windows with the same setup and draw the exact same triangle. I get the result below, which is the expected result. Anyone can help me figure out how to get this same result on the phone?
I have already put
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>
tag in AndroidManifest.xml. In particular, I found that it seems like only android:anyDensity="true"|”false” matters, as this does change the rendered result. Others don’t change the result at all. Also my project is on SDK 1.6, which is recommended for developing apps that support larger phone screen.
The original question is also asked here: http://www.anddev.org/viewtopic.php?p=34832#34832