Clicking on the screen.

I was wondering if there is an easy way to figure out where, in 3D a user clicked on the screen. I’m using GLUT, so I can easily get the actual (x,y) values, but I need to convert that into OpenGL numbers.

If you’ve just clicked in your window at x,y then your coordinates in 3d space will be left_edge_of_vision + (x/window_width)*vision_width, bottom_edge_of_vision + (y/window_height)*vision_height. This is of course ignoring the ‘depth’ of your click since there wasn’t any to be measured.

It might be time for you to review your algebra/trig. Good luck!

If you are trying to get the depth of something you have already rendered, you could always try this-


tmpFloat will contain the depth(0.0-1.0) of wherever you clicked.

[This message has been edited by Sheepie (edited 05-29-2001).]

do a search on picking in both forums…