Sounds like you’re generally on the right track, but it’s unclear exactly what you’re loading on the PROJECTION matrix. glOrtho, gluOrtho2D, glFrustum, gluPerspective. Any of these (alone on top of an glLoadIdentity) is good. glScale? Now that’s not good. That’s called “Projection Abuse”.
Just to be clear, there are a few ways to “zoom” on object (i.e. make something appear bigger on the screen. One is to reduce the size of the frustum. You can do that with the Ortho or Frustum calls (on the PROJECTION stack of course) reducing right-left and/or top-bottom. Or you can do it with Frustum (again, on PROJECTION stack) by pushing near out. Or you can do it with Perspective in the obvious way of reducing fovy and/or aspect.
Another way to “zoom” (when you have a perspective transform active on the PROJECTION stack) is to just use the MODELVIEW stack to move the eyepoint closer to the object (i.e. change the VIEWING transform) or move the object closer to the eyepoint (i.e. change the MODELING transform). Then its apparent size increases in your field of view. You could do the former with gluLookAt and the latter with glTranslate on the MODELVIEW stack (at the appropriate time).
Yet another way to make an object bigger is to change it’s size via a scale transform on the MODELVIEW stack when you’re rendering your object. You could do this with glScale on the MODELVIEW stack for instance. I generally avoid this because it means you have to tell the GPU to normalize normals to get your lighting to work in your shader, not to mention that most real world objects don’t physically grow and shrink, but you can definitely do this.
Any of these are fine. Which one is better depends on your specific requirements for how things need to look in your application. For instance, how do other objects in the scene need to appear when you’re “zooming” that specific object?
but it’s unclear exactly what you’re loading on the PROJECTION matrix. glOrtho, gluOrtho2D, glFrustum, gluPerspective.
I mainly prefer to use glOrtho(), to have a “parallel projection view”, like users of mechanical cad applications often prefer. I have to study better glFrustum, to add the option of a perspective view.
You can do that with the Ortho or Frustum calls (on the PROJECTION stack of course) reducing right-left and/or top-bottom.
Yes, when the user interact with the mouse to get zooming, it changes a zooming parameter that modify the right-left and top-bottom values of the call to glOrtho (and near-far too, because of clipping), with respect of the aspect ratio between height and width (glViewport).
Yet another way to make an object bigger is to change it’s size via a scale transform on the MODELVIEW stack when you’re rendering your object.
For instance, how do other objects in the scene need to appear when you’re “zooming” that specific object?
I prefer not to use this approach, because I want to manage separately the viewing transformation to render the scene (using Opengl) from the mathematical rapresentation of my objects (not using Opengl), ie if I want to scale an object I change it’s mathematical definition, it is not a viewing problem.
For zooming, my doubt was between using the glOrtho/glFrustum/GL_PROJECTION approach or the glScale/GL_MODELVIEW approach(but for the entire scene),
No, think about it. Where are the L,R,B,T values defined with a perspective Frustum transform? On the near clip plane. Push the near clip plane out (while leaving L,R,B,T alone), and you just reduced your FOV (which of course makes things in the center of the frustum bigger in the new FOV).
…unless I’m missing something obvious which is certainly possible.