Here is what I am trying to do : I am drawing a 2D image ( a bitmap ) in my GL Window, using glDrawPixels. Nothing complicated so far.
Then, I am drawing a OpenGL object in the middle of it. It currently overlaps the entire “section” where it is drawn, of course.
Now the tricky part : I would like to give depth values to my 2D Image Pixels so that GL could consider these values when doing Depth Calculations with the GL Quad.
In other words : I would like that my 2D Image Pixels have Depth Values so that the 3D shape that would result could intersect with the GL Objects I would draw after. So that I could be able to tell which pixels are in front of my GL object, and which ones are behind. That way, pixels of the GL object could be occluded by pixels from the 2D Images.
Also, you might try reading the depth values back.
Also, try drawing your polygon so that the top edge is at the far end of the view volume and the bottom is at the near end, then you should see some effect.