PDA

View Full Version : Clicking on the screen.



2
05-29-2001, 10:37 AM
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.

BlueJ
05-29-2001, 11:17 AM
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. http://www.opengl.org/discussion_boards/ubb/wink.gif

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

Sheepie
05-29-2001, 07:43 PM
If you are trying to get the depth of something you have already rendered, you could always try this-

glReadPixels(mouseX,(height-mouseY),1,1,GL_DEPTH_COMPONENT,GL_FLOAT,tmpFloat);

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

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

DaViper
05-29-2001, 11:56 PM
do a search on picking in both forums...