PDA

View Full Version : Pan view with bad ratio



05-07-2006, 02:00 PM
Hello experts,

I just cannot get the view to pan with the same ratio as I move the mouse. Especially not when I have zoomed in or out to a great extent (scale != 1.0)

Here is my code (in Java)

GL gl = drawable.getGL();

gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(left*scale*asph,right*scale*asph,bottom *scale/aspv,top*scale/aspv,Znear,Zfar);

gl.glMatrixMode(GL.GL_MODELVIEW); gl.glClear(GL.GL_COLOR_BUFFER_BIT |GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();

gl.glPushMatrix();
// translate the model
gl.glTranslated(transX,transY,0.0);

// rotate the model
gl.glMultMatrixf(matrix, 0);

// Set color
gl.glColor3f(0.0f, 0.0f, 0.0f);


// Draw each element
......

gl.glPopMatrix();
gl.glFlush();TransX and TransY contains the accumulated mouse movements (pixels).

scale is a zoom factor

asph is the view aspect ratio to keep is square.

Can anyone see the problem or guide me in the right direction?

Many Thanks
/Jonas