where did i click?

here is a problem that i have, i render some 3d
world and i enable user to pick objects, but how
could i recieve the 3D world coordinates of the
place under the mouse cursor where it picked the

Have a look at http://www.lighthouse3d.com/opengl/picking/
hope it helps thanx

i already have that, but i need the world XYZ coords of where the cursor touches the world geometry…

I use the “Object Selection Using the Back Buffer” method as described in The Red Book:

Basically, after rendering my scene as usual with swap at the end, I just re-render all of the objects in the scene with a unique filled color (make sure multi-sample or antialias is turned off) into the back buffer but do not swap it when completed. When I click in the window I read back the single pixel from the back buffer. I use the read color figure out which object is hit.

When more information is needed I add a unique color for each surface to get more detailed location information.

For the world XYZ coordinates, just read out the DEPTH value at the clicked window coordinates (using glReadPixels) and then convert the window coordinates to world coordinates with the gluUnProject function.