views:

180

answers:

1

I have a simple iPhone OpenGL ES app, in which I render a full-screen background image using a texture, and then draw 3D polyhedra on top of it using lines. The texture is displayed using glDrawTexfOES.

The problem is that I don't seem able to display the polyhedra on top of the background. In the glDrawTexfOES call, if I use a z value of less than 1, the background image shows but no polyhedra. If the z value is 1 (or more), the polyhedra show but not the background image.

Blending is not enabled. Depth testing is on. Depth buffer attached. Depth testing seems to be working when just the polyhedra are drawn. The polyhedra are drawn with simple lines.

The z value behavior suggests that maybe the polyhedra have depth buffer values of 1...?

Any clues to how to get both background image and foreground objects displayed?

A: 

My guess, when you're drawing the background image disable the depth mask. This will ensure the depth buffer is left untouched when you lay down the backdrop so that the polyhedra are drawn and not failing the depth test.

Do a simple test and scale down the backdrop and then scale up the polyhedra and render using your original algorithm. You should see your geometries everywhere where either the background isn't, as well as anywhere the polyhedra actually pass the depth test.

Samuel
Thanks, Samuel. I'll give that a shot and report back.
bfalling