Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: GL_DEPTH_TEST affects blend result

  1. #1
    Junior Member Newbie
    Join Date
    May 2013

    GL_DEPTH_TEST affects blend result

    While doing a simple blend operation, textured quad over background:

    Code :
    glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );  // texture is pre-multiplied
    // texture
    glActiveTexture( GL_TEXTURE0 );
    glEnable( GL_DEPTH_TEST );
    glDepthFunc( GL_ALWAYS );
    // draw quad
    glBindTexture( GL_TEXTURE_2D, textureId ); // this bind will stop the pipeline if the pbo to texture update isn't finished
    CORE_GL_CHECK( "bind texture" );
    painter->setUserEffect( );
    quadData.draw(, 0, quadData.indexCount(), QGL::TriangleStrip, 1.0 );
    glDisable( GL_DEPTH_TEST );
    glBindTexture( GL_TEXTURE_2D, 0 ); // unbind texture

    If the DEPTH_TEST is removed a nasty black border affects the blend operation, see the right image in the attachment.

    Any ideas? I'm trying to track down why it happens, it's most likely related to misuse of glcalls but I can't find where.


    Click image for larger version. 

Name:	blendartifact.jpg 
Views:	125 
Size:	14.7 KB 
ID:	1353

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    UK, London
    For most "2D" operations you usually don't enable depth testing, or at the very least disable writing to the depth buffer.
    gldepthmask (GL_FALSE)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts