PDA

View Full Version : Zooming in Open GL



jowins
12-28-2002, 02:01 AM
Hi Friends,
I have an Open GL window which draws Waterfall graph and allows rotation. Based on a rectangle portion selected by mouse I want to Zoom the selected portion of the graph. How can I do that?
How can I map the Windows X and Y position to that of Open GL x,y and z coordinates?
Thanks
jowins

V-man
12-28-2002, 10:13 AM
Originally posted by jowins:
Hi Friends,
I have an Open GL window which draws Waterfall graph and allows rotation. Based on a rectangle portion selected by mouse I want to Zoom the selected portion of the graph. How can I do that?
How can I map the Windows X and Y position to that of Open GL x,y and z coordinates?
Thanks
jowins

You can map anyway you like. It depends. After you computer your new rectangular region, you have to renew your projection matrix :

glLoadIdentity();
glFrustum(newL, newR, newB, newT, near, far);

There are other ways to. You can make use of gluPickMatrix() like this

glLoadIdentity();
gluPickMatrix(......)
glFrustum(oldL, oldR, oldB, oldT, near, far);

In this case, gluPickMatrix does the job for you.

V-man

HanWu
11-14-2006, 05:52 PM
Originally posted by V-man:

Originally posted by jowins:
Hi Friends,
I have an Open GL window which draws Waterfall graph and allows rotation. Based on a rectangle portion selected by mouse I want to Zoom the selected portion of the graph. How can I do that?
How can I map the Windows X and Y position to that of Open GL x,y and z coordinates?
Thanks
jowinsYou can map anyway you like. It depends. After you computer your new rectangular region, you have to renew your projection matrix :

glLoadIdentity();
glFrustum(newL, newR, newB, newT, near, far);

There are other ways to. You can make use of gluPickMatrix() like this

glLoadIdentity();
gluPickMatrix(......)
glFrustum(oldL, oldR, oldB, oldT, near, far);

In this case, gluPickMatrix does the job for you.

V-man Hi V-man, I would like to know how to calculate the newL,newR,newB, newT base on the mouse position (X,Y) and say the width and height are 100 and 100 respectively?