PDA

View Full Version : help with orthographic zoom



mark-w
08-12-2005, 01:06 PM
Hi all,

I have been trying to support zooming operations in an orthographic projection. I have gotten most of the way in the beginners forum, I'm hoping someone can clarify how to finish this zooming.

I am displaying a bitmap as a texture mapped quad. I want to be able to have the mouse movements over the quad show what actual pixel back in the original bitmap that mouse location corresponds to.

I am using glTranslate() for panning the quad, and glScalef() for 'fake' zooming of the quad. I can get the bitmap pixel location by taking the actual windows mouse location and subtracting the pan offset and then dividing by the scale factor, this works really nicely.

So my last problem here is that when I use glScalef(), the scaling happens from the origin (bottom left) of my worldview, so the zooming doesn't look quite nice (quad grows from lower left corner of the viewport). I would like scale operations to be done around the center of the viewport if possible. Should I just call glTranslate() after each scaling operation to move the quad so it looks like it is remaining in place during the zoom?

Posts in this forum have suggested using glOrtho() to zoom in an orthographic projection instead of glScalef(), which I am not opposed to, but if I use that, how can I still correctly query the original pixel locations when the mouse goes over the quad?

Thanks,
Mark

Shawn B
08-12-2005, 06:54 PM
For your problem of scaling, couldn't you do Triangle strips and set the orgin at the center, and create the triangle outward. You could even make it in a function or a list then just scale it from there.

dorbie
08-12-2005, 06:59 PM
glOrtho is your friend, adjust the numbers you call it with.