Picking problem

Hello guys.

I’m trying to implement picking with glSelect, is is working but if I have picked one object like in the point that it intersect with another, I have problems, I think it will generate more than one hit, right ? Ok this is working :

if(hits == 1) Perform_Selection();
if(hits > 1) // Show a special message

The message is being displayed, but now, how to control the ID of the next hit (next object) ??

Hope I’m clear enough.
Thank you for the moment.
Best regards.
Kurt

You need to move through the buffer specified in glSelectBuffer looking for the hit with the closest z value. I think Each hit fills up 4 elements in the buffer, the 2nd is the z value, and the 4th is the Name that you gave the object. Someone correct me if I’m wrong please.

Hope that helps