Zooming in Open GL

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

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

Originally posted by V-man:
[b] [quote]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 [/b][/QUOTE]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?