gluUnproject depth buffer read?

I got selection working using gluUnproject, but I can’t seem to get the depth buffer read to work so I can make sure the correct model i selected. Right now I just shoot from 0…1 depth which finds all objects in it’s path.
I remember an example being posted here, but I just can’t seem to find it. Anyone got a working example or the old example in question?

Thanks in advance :slight_smile:

Hi, no example at hand but if I remember well you’ll always get z coordinate between 0 and 1, since the value is scaled into this range… So it should work in any case.

I don’t think so. gluUnProject needs a depth value, so you’ll have to read the depth value before passing it to gluUnproject. If I remember correctly that is :slight_smile:

Yes, i understand, but my point is that the value you’ll read will be bound to 0…1

Edit : Verification, extract from glReadPixelsDoc

    GL_DEPTH_COMPONENT
            Depth values are read from the depth buffer.  Each component is converted to floating point such that the      minimum      depth value maps to 0 and the maximum value maps to 1.  Each component is      then multiplied by GL_DEPTH_SCALE, added      to
            GL_DEPTH_BIAS, and finally clamped to the range
            [0,1].

So i may have remembered well (for once :P).

Ahh ok. I meant that my ray starts at 0 and ends at 1 so it hits all objects in it’s path from the front to the back plane.
But I’ll just add the glreadpixels thingie tomorrow and it’ll probably work :slight_smile: