Selection mode. No pixel fragments are produced, and no change to the framebuffer contents is made. Instead, a record of the names of primitives that would have been drawn if the render mode was GL_RENDER is returned in a select buffer, which must be created (see glSelectBuffer) before selection mode is entered.
After clearing the depth buffer, rendering with GL_SELECT, and (successfully) getting my selection, the depth buffer appears to be completely empty…but if I render in regular mode, the depth buffer gets filled and returns correct information.
glGetIntegerv GL_DEPTH_WRITEMASK says that writing to the depth buffer is enabled, but maybe OpenGL doesn’t consider rendering in GL_SELECT to be something that writes to the depth buffer?
Is this right? Do I have to render again in regular mode just to get the picked z-position?
Yeah, this is correct. I just went back and rendered only the closest object, and it works now.