Using java Syntax Highlighting
- @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);
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
The coordinates for the triangle are:
Using java Syntax Highlighting
- float[] coords = {
- // X, Y, Z
- 0.0f, 0.0f, 0,
- 200.0f, 200.0f, 0,
- 100.0f, 0.0f, 0,
- };
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
And I get the result in the second attachment. The result is same on emulator 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 with the same setup and draw the exact same triangle. I get the result in the first attachment, which is the expected result. Anyone can help me figure out how to get this same result on the phone?


