View Full Version : GL_DEPTH_TEST affects blend result

07-04-2014, 01:56 PM
While doing a simple blend operation, textured quad over background:

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( 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.



07-09-2014, 06:51 AM
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)