Ok. Some code.
In the display method:
display()
{
…
…
…
// PositionCamera
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(fov_y, aspect, near_z, far_z);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(eye[0], eye[1], eye[2],lookat[0], lookat[1], lookat[2], 0.0f, 1.0f, 0.0f);
/* Save projection and modelview matrices for later use */
gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, model);
gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, proj);
…
…
…
if (mousepressed)
{
call unproject()
}
…
…
…
int worldLeft = (int)camera.worldLeft;
int worldRight = (int)camera.worldRight;
int worldBottom = (int)camera.worldBottom;
int worldTop = (int)camera.worldTop;
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D, terrainTextureId[0]);
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glDepthFunc(GL.GL_ALWAYS);
gl.glEnable(GL.GL_ALPHA_TEST);
gl.glAlphaFunc(GL.GL_GREATER, 0.0f);
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2f(0f, 0f);gl.glVertex3f(worldLeft, 1f, worldBottom);
gl.glTexCoord2f(0f,1f);gl.glVertex3f(worldLeft, 1f, worldTop);
gl.glTexCoord2f(1f,1f);gl.glVertex3f(worldRight, 1f, worldTop);
gl.glTexCoord2f(1f,0f);gl.glVertex3f(worldRight, 1f, worldBottom);
gl.glEnd();
gl.glDisable(GL.GL_TEXTURE_2D);
}
Now to zoom in I change the eye[] values and call canvas.display(). This seems to work although I get some unexpected results sometimes, but that’s another matter.
Can anybody see what I’m doing wrong