Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

biosopher

macrumors newbie
Original poster
Jan 15, 2009
8
0
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
USE_DEPTH_BUFFER_0.png


Image with USE_DEPTH_BUFFER = 1
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

macrumors newbie
Original poster
Jan 15, 2009
8
0
Should have added for those that don't have the GLSprite code. This is what the USE_DEPTH_BUFFER code enables:

Code:
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

macrumors newbie
Original poster
Jan 15, 2009
8
0
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
Alpha Blending, Part 2
Alpha Blending, Part 3

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

Anthony
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.