Modifying Depth Buffer Values

Hi there,

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.

Have I been clear enough ? :slight_smile:

Anyone could give me a hint on that one ?

Thanks

IIRC, you can also use glDrawpixels with GL_DEPTH_COMPONENT to draw depth values to the framebuffer.

Note that using drawpixels is not the most efficient way of drawing to the framebuffer, but as long as performance is not an issue, this’ll do the trick.

Greetz,

Nico

performance would be an issue since the 2D image would be processed from a camera, at 15fps+.

I tried the GL_DEPTH_COMPONENT thingie, but my GL objects never get rendered.

Quad is drawn at (0,0,0), (0,60,0), (60,60,0) (60,0,0) and is being viewed from a distance of 600.

I tried both positive and negative depths. Not working.

But since as I said, performance is an issue, i’d like to hear about other ways to do that

Thanks

no one knows about it ? :confused:

I’ve never used this, but I know I’ve seen it work.

I’d look at this page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc03_8m7n.asp

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.