How to select objects in 3D?

I was quiet enthusiastically reading the chapter of redbook on selection, hoping to find a solution to my object picking problem for my project. To my disappointment, it didn’t give a method to distinguish between objects at different depths, but which lie at the same cursor position. So once again, seeking the help of real opengl people over here. I simply want to select that object which lies at the frontmost. I have enabled depth buffering.


Look at the pickdepth.c example in the RedBook? Try running it and notice how the closer square (name 1) has the lower depth value (0.333333). The lower the depth … the closer it is.

OOps! I think i was in a hurry to read the chapter!