This code:
public void onSurfaceChanged(GL10 gl, int w, int h) {
gl.glViewport(0, 0, w, h);//
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
// set camera zoom
GLU.gluPerspective(gl, 45.0f,(float) w / h, 0.1f, 100.0f);
// point camera
GLU.gluLookAt(gl, 0, 1, 5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
}
public void onDrawFrame(GL10 gl) {
// clear last frame
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
// set model and projection matrices to identity
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, 0, 1, 5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
square.draw(gl);
}
works as expected on the emulator (on Android 2.1 virtual device) but on phone (HTC Desire Android 2.1) it just clears the screen, can't see anything drawn. If I comment out the
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, 0, 1, 5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
it works on the phone, but not if I have the gluLookAt call in onDrawFrame.
What's the problem with gluLookAt in onDrawFrame?