The topic of this article is focused around zooming in a perspective OpenGL view. I wrote this article because I found some examples of zooming in a OpenGL view using ortho projections. But the most advanced example that I found using perspective projections, don't implement a true zooming but simulate the zooming effect changing the view point or camera angle. The technique that I suggest implement a true zooming and not change camera angle or perspective parameters (view point, reference point clipping planes). I achieved this result using the function
glFrustum instead of standard
gluPerspective and manipulating (see function
COGL::SetPerspective(const CRect &rcClient) in the class
COGL) the scaling and translating parameters of projection matrix. Two normalized rectangles are maintained by the
COGL class: one for the full size image, and one for the current zooming rectangle. The image presented by OpenGL is scaled by the ratio of the rectangles, adjusted according to the viewport aspect and translated to the center of current zooming rectangle.
Finally sorry for my poor English.