13,292,205 members (55,746 online)
alternative version

#### Stats

244.7K views
63 bookmarked
Posted 11 Feb 2002

# True OpenGL Zooming

, 11 Feb 2002
 Rate this:
True zooming on a perspective view...

## Introduction

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.

A list of licenses authors might use can be found here

## Share

 Italy
No Biography provided

## You may also be interested in...

 View All Threads First Prev Next
 Small question about OpenGL Anonymous28-May-02 1:05 Anonymous 28-May-02 1:05
 Re: Small question about OpenGL Ali Khanlarkhani19-Jan-03 1:33 Ali Khanlarkhani 19-Jan-03 1:33
 This is how M3D(x, y, z) can be convert to M2D(x, y): ```void Project(double x3D, double y3D, double z3D, double *pXWin, double *pYWin)
{
/* -------{ VARIABLE SECTION }------- */
GLdouble model_matrix[16];
GLdouble project_matrix[16];
GLint viewport[4];
double dummy_z;
/* -------{ INITIALIZATION SECTION }------- */
// Make Current Rendering context
/* -------{ MAIN SECTION }------- */
glGetDoublev(GL_MODELVIEW_MATRIX, model_matrix);
glGetDoublev(GL_PROJECTION_MATRIX, project_matrix);
glGetIntegerv(GL_VIEWPORT, viewport);
gluProject(x3D, y3D, z3D, model_matrix, project_matrix, viewport, pXWin, pYWin, &dummy_z);
/* -------{ RETURN SECTION }------- */
return;
}
```
 Last Visit: 31-Dec-99 19:00     Last Update: 13-Dec-17 3:44 Refresh 1