View Full Version : Zooming and Preserve aspect ratio

05-16-2006, 12:11 PM
thanks to some replies here I succeded in display a buffer from camera using OpenGL(Topic: "cropping" 2d texture).
Now I'd like to perform(using OpenGl) a zoom when the user click on a certain pixel, I can get the coordinates by gluUnProject, but I don't know how to have in my window only a portion of the area zoomed.

Another thing I'd like to do is to maintain the ratio of my buffer showing black bars on the sides, I think glOrtho could be right but I cannot understand how to use it.

Thanks again


05-17-2006, 05:53 AM
Orthographic projection is a "fake" 3D view without perspective depth and works fine for displaying 2D stuff like your image, i.e things don't get smaller with distance, if you look at gluPerspective you specify a "field of view" value, this is the "zoom factor" that indicates how much to show in the window, you can do this yourself with the left,right,top,bottom values in glOrtho or gluOrtho2D, this values specify how much to show of the world in your window, so by changing those values you can "zoom" in and out.

Example, if you use -1,1,1,-1 for your left,top,right,bottom values and change this to -0.8,0.8,0.8,-0.8 you will zoom in because you display a smaller part of your world in the same window.

Hope that helps on your way...