PDA

View Full Version : USE_DEPTH_BUFFER = 1 affects alpha of textures!?!




biosopher
Jan 17, 2009, 08:51 PM
In Apple's GLSprite (and probably the TouchFighter code as well), setting USE_DEPTH_BUFFER = 1 affects the alpha of textures such that any transparent pixel becomes black.

I.e. if all I do is change the single value of USE_DEPTH_BUFFER from 1 to 0, I get the transparency I want. Why the dependency between transparency and USE_DEPTH_BUFFER? What am I missing here?

Image with USE_DEPTH_BUFFER = 0
http://www.pocketjourney.com/downloads/forum_posts/USE_DEPTH_BUFFER_0.png

Image with USE_DEPTH_BUFFER = 1
http://www.pocketjourney.com/downloads/forum_posts/USE_DEPTH_BUFFER_1.png

I don't understand how creating the depth buffer affects whether the image-based textures are transparent or not. Any ideas?

Anthony



biosopher
Jan 17, 2009, 08:55 PM
Should have added for those that don't have the GLSprite code. This is what the USE_DEPTH_BUFFER code enables:


if (USE_DEPTH_BUFFER) {
glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
}

biosopher
Jan 17, 2009, 09:43 PM
OK...maybe I was just optimistic that I could have OpenGL handle my depth testing automatically AND get transparencies as well.

I just read these discussions of depth testing & alpha transparencies that are telling me otherwise...or at least seem to layout a more complex solution than the simple one I'd hoped for:

Alpha Blending, Part 1 (http://blogs.msdn.com/etayrien/archive/2006/12/07/alpha-blending-part-1.aspx)
Alpha Blending, Part 2 (http://blogs.msdn.com/etayrien/archive/2006/12/12/alpha-blending-part-2.aspx)
Alpha Blending, Part 3 (http://blogs.msdn.com/etayrien/archive/2006/12/19/alpha-blending-part-3.aspx)

Please let me know if anyone knows can direct me to better discussions or tutorials.

Anthony