12,397,805 members (57,807 online)
alternative version

228.6K views
63 bookmarked
Posted

# 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.

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

## About the Author

 Italy
No Biography provided

## Comments and Discussions

 View All Threads First Prev Next
 Small question about OpenGL Anonymous28-May-02 0:05 Anonymous 28-May-02 0:05
 Re: Small question about OpenGL Ali Khanlarkhani19-Jan-03 0:33 Ali Khanlarkhani 19-Jan-03 0: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 18:00     Last Update: 25-Jul-16 7:44 Refresh 1

General    News    Suggestion    Question    Bug    Answer    Joke    Praise    Rant    Admin

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.