Part of the Khronos Group
OpenGL.org

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
    Posts
    3

    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
    painter->clearAttributes();
    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( effect.data() );
    quadData.draw( painter.data(), 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.

    Mikael




    Click image for larger version. 

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

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,170
    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
  •