USE_DEPTH_BUFFER = 1 affects alpha of textures!?!

Discussion in 'iPhone/iPad Programming' started by biosopher, Jan 17, 2009.

  1. macrumors newbie

    Joined:
    Jan 15, 2009
    #1
    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
    [​IMG]

    Image with USE_DEPTH_BUFFER = 1
    [​IMG]

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

    Anthony
     
  2. thread starter macrumors newbie

    Joined:
    Jan 15, 2009
    #2
    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);
    }
    
     
  3. thread starter macrumors newbie

    Joined:
    Jan 15, 2009
    #3
    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
     

Share This Page