How can I convert the x-y coordinates obtained in the glutMouseFunc to world coordinates? I want to allow the user to zoom in on a particular part of the scene, centred on the mouse position clicked; maybe even to select a rectangle within the window to zoom in on. What would be the best way of achieving this?


gluUnProject (or selection buffer) - do a search

I tried this out, it seems to work sometimes, which is definitely bad. What am I doing wrong?

/*calculate the width, ht & centre of the zoom window*/
width = maxX - minX;
ht = maxY - minY;
cX = minX + width/2;
cY = minY + ht/2;

/*get current viewport*/
glGetIntegerv(GL_VIEWPORT, viewport);

/*initialise projection mode*/

/*zoom in*/
gluPickMatrix(  (GLdouble)cX, (GLdouble)cY, 
		(GLdouble)width, (GLdouble)ht, viewport);
/*multiply perspective matrix by the pick matrix*/
gluPerspective(90, width/ht, -0.8, 0.8);

Also, how should I decide what values to use for near & far z clipping planes for gluPerspective?

How can I trace out the picking rectangle drawn by the user as they drag the mouse?(I’m doing this in X)

Pls help…thanks.

The following website might of some help: http://cheo.resnet.wayne.edu/miguel/

I remind there is a sample in this website that Zoom In using mouse