PDA

View Full Version : Modifying Depth Buffer Values



Whilibarj
09-07-2004, 10:45 AM
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 ? :)

Anyone could give me a hint on that one ?

Thanks

-NiCo-
09-07-2004, 11:03 AM
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

Whilibarj
09-07-2004, 11:21 AM
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

Whilibarj
09-09-2004, 02:51 PM
no one knows about it ? :confused:

endash
09-09-2004, 04:56 PM
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.