PDA

View Full Version : Zoom problem



ibanezul
12-05-2008, 01:48 AM
Hi everyone,

I want to zoom in on a 2D drawing in OpenGL and so I modify the clipping area when a button is pressed. The zoom algorithm is very simple:

float initialWidth=Math.abs(screenArea.maxX-screenArea.minX);
screenArea.minY += zoomSize;
screenArea.maxY -= zoomSize;
float zoomedWidth=Math.abs(screenArea.maxY-screenArea.minY)*aspectRatio;
screenArea.minX += (initialWidth-zoomedWidth)/2;
screenArea.maxX -= (initialWidth-zoomedWidth)/2;

gl.glOrthof(screenArea.minX, screenArea.maxX,screenArea.minY, screenArea.maxY, 1, -1);

This goes very well up to a certain point, where
screenArea.minX = 3096.8154f;
screenArea.maxX = 3152.815f;
screenArea.minY = 5648.5005f;
screenArea.maxY = 5723.7495f;

From here on, there is no more zooming, but the whole image pans out on the Y axis (the pan is exponential: at the first click it moves a little, at the second click more, etc).

I'm doing this with OpenGL ES for the Android platfrom. Might this be a bug, or I'm doing something wrong?

PS: If I substract from every X coordonate in the scene minX and from every Y coordonate mixY (I translate the whole thing to origin) it works perfectly

Any help would be greatly appreciated.
Thanks in advance.

ZbuffeR
12-05-2008, 03:52 AM
Sounds like you hit precision issues of your plateform.
What implementation of OpenGL ES do you use ?

ibanezul
12-05-2008, 03:56 AM
Quote from the Android website: "Android currently supports OpenGL ES 1.0, which corresponds to OpenGL 1.3"

ZbuffeR
12-05-2008, 03:59 AM
That does not say anything about the implementation.
Well I am pretty sure that ES 1.0 can use low precison fixed point arithmetic.

ibanezul
12-05-2008, 06:44 AM
I also tried with fixed point numbers...same result :(

Another strange behaviour: if I set the vieport smaller than the window, the drawing will pan out of the viewport area and into the rest of the window area.

Any ideas?