Click here to Skip to main content
11,410,750 members (63,982 online)
Click here to Skip to main content

True OpenGL Zooming

, 11 Feb 2002
Rate this:
Please Sign up or sign in to vote.
True zooming on a perspective view...

Sample Image - Zoom.jpg


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

No Biography provided

Comments and Discussions

GeneralAbout 3D point PinmemberEduardo Tucci29-Jun-10 16:54 
QuestionPanning in perspective view? PinmemberHan Wu17-Nov-06 6:27 
Generali want to use 3dmax , opengl and c# Pinmembereey5630-Oct-06 22:53 
Generalopengl control ... Pinmemberdoudicool5-May-06 12:34 
GeneralAdd Scroll Bar Pinmemberanil6-Sep-05 23:14 
Generalzooming Pinmembersreejith ss nair28-Apr-05 21:24 
QuestionHow To Load 3DMax Objects in OpenGL? Pinmemberobaid salikeen26-Apr-05 0:31 
Generalis it possible to use it for dialogs Pinmembernandeeshds28-Oct-04 6:05 
QuestionHow to run 2 different(or same) OpenGL objects in one DialogBox? Pinmemberwerter13-May-04 22:10 
QuestionHOW TO DRAW A CIRCULAR SCALE? Pinmemberprath8-Apr-03 3:46 
Questionhow to ZOOM? Pinmemberprath8-Apr-03 3:43 
General3D coordinate Pinmembereddymohd19-Feb-03 23:24 
GeneralRe: 3D coordinate Pinmembertopus19-May-03 3:21 
GeneralRe: 3D coordinate PinsussAnonymous9-Jun-05 5:58 
GeneralSmall question about OpenGL PinmemberAnonymous28-May-02 1:05 
GeneralRe: Small question about OpenGL PinmemberAli Khanlarkhani19-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 }------- */

GeneralHey Man PinmemberRick York16-Feb-02 14:09 
GeneralAn Easier Way.... PinmemberFatBuddha13-Feb-02 8:34 
GeneralRe: An Easier Way.... Pinmemberpepito sbarzeguti13-Feb-02 22:30 
GeneralRe: An Easier Way.... PinmemberFatBuddha14-Feb-02 8:00 
GeneralRe: An Easier Way.... PinmemberAlberto Bencivenni12-Dec-05 4:06 
GeneralRe: An Easier Way.... Pinmembera_david12322-Jun-07 0:36 
GeneralBroken link's Pinmemberpepito sbarzeguti12-Feb-02 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150414.5 | Last Updated 12 Feb 2002
Article Copyright 2002 by pepito sbarzeguti
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid