Opengl Es Object Is Displaying Strangely / Distorted - Android
EDIT OK - I grabbed a device and..guess what...it displays correctly ? Does anyone know why this would be happening on the simulator only ? Thank you. I am trying to draw an object
Solution 1:
I'm a bit confused by what you're doing. Why do you wipe on the projection matrix in onDrawFrame
, after setting it in onSurfaceChanged
?
You should set projection in onSurfaceChanged like so:
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity(); //make sure to reset before glOrthof
gl.glOrthof(0, 320f, 480f, 0, 0, 1);
}
And then change back to modelview and don't disturb the projection matrix during onDrawFrame
.
You'll probably need to recalibrate your scale and translate in onDrawFrame
as well after doing this.
Post a Comment for "Opengl Es Object Is Displaying Strangely / Distorted - Android"