I found on the web that I could use gluPickMatrix to zoom in on part of the scene.
Currenlty I have:
public void reshape(GLAutoDrawable drawable,int xstart,int ystart,int width,int height) {
GL gl = drawable.getGL();
height = (height == 0) ? 1 : height;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluOrtho2D(0.0, width, 0.0,height);
// mover the origin from the bottom left corner
// to the upper left corner
gl.glScalef(1, -1, 1);
gl.glTranslatef(0, -height, 0);
// select modelview matrix and clear it out
gl.glMatrixMode(gl.GL_MODELVIEW);
}
So based on that I have created
public void zoom(GL gl, int xstart,int ystart,int width,int height) {
int[] vp = new int[4];
//Initialise projection mode,...
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
//...get viewport details,...
gl.glGetIntegerv(GL.GL_VIEWPORT, vp,0);
int[] zoomport = new int[4];
zoomport[0] = xstart;
zoomport[1] = ystart;
zoomport[2] = width;
zoomport[3] = height;
//Then use pickmatrix to zoom in on this part of the scene...
glu.gluPickMatrix(zoomport[0]+zoomport[2]/2, zoomport[1]+zoomport[3]/2, zoomport[2], zoomport[3], vp,0);
glu.gluOrtho2D(xstart, width, ystart,height);
// mover the origin from the bottom left corner
// to the upper left corner
gl.glScalef(1, -1, 1);
gl.glTranslatef(0, -height, 0);
// select modelview matrix and clear it out
gl.glMatrixMode(gl.GL_MODELVIEW);
}
the latter function will be called after I have defined the coordonates of the Zoom rectangle with the mouse. Can someone pls tell me if this is a correct way to do this, and what about if I resize the window while in zoom mode?