diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-11-07 11:08:49 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-07 19:13:30 +0100 |
commit | 734f424ee97fc74027f2717c592c0b329e41573b (patch) | |
tree | 8eada28320d34ba313931de7bbca8cb411effd74 /src/quick/items/qquickshadereffectsource.cpp | |
parent | c29e825ec6064aa266f0082b3d3b1cb0ceb0809a (diff) |
Fill recursive ShaderEffectSource with transparent when using alpha.
The logic relies on m_fbo being 0 on the first render pass, in which
case it will pick texture id 0 which is solid black. Though this
works ok, it results in recursive shader effect sources starting
out black which is ugly.
Change-Id: I22b1d50e02c00583837b8152c5fb850263038a93
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/quick/items/qquickshadereffectsource.cpp')
-rw-r--r-- | src/quick/items/qquickshadereffectsource.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp index c05545c292..e076a342df 100644 --- a/src/quick/items/qquickshadereffectsource.cpp +++ b/src/quick/items/qquickshadereffectsource.cpp @@ -141,6 +141,7 @@ QQuickShaderEffectTexture::QQuickShaderEffectTexture(QQuickItem *shaderSource) , m_renderer(0) , m_fbo(0) , m_secondaryFbo(0) + , m_transparentTexture(0) #ifdef QSG_DEBUG_FBO_OVERLAY , m_debugOverlay(0) #endif @@ -165,6 +166,8 @@ QQuickShaderEffectTexture::~QQuickShaderEffectTexture() #ifdef QSG_DEBUG_FBO_OVERLAY delete m_debugOverlay; #endif + if (m_transparentTexture) + glDeleteTextures(1, &m_transparentTexture); } int QQuickShaderEffectTexture::textureId() const @@ -189,8 +192,20 @@ void QQuickShaderEffectTexture::bind() if (!m_recursive && m_fbo && ((m_multisampling && m_secondaryFbo->isBound()) || m_fbo->isBound())) qWarning("ShaderEffectSource: \'recursive\' must be set to true when rendering recursively."); #endif - glBindTexture(GL_TEXTURE_2D, m_fbo ? m_fbo->texture() : 0); - updateBindOptions(); + + if (!m_fbo && m_format == GL_RGBA) { + if (m_transparentTexture == 0) { + glGenTextures(1, &m_transparentTexture); + glBindTexture(GL_TEXTURE_2D, m_transparentTexture); + const uint zero = 0; + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &zero); + } else { + glBindTexture(GL_TEXTURE_2D, m_transparentTexture); + } + } else { + glBindTexture(GL_TEXTURE_2D, m_fbo ? m_fbo->texture() : 0); + updateBindOptions(); + } } bool QQuickShaderEffectTexture::updateTexture() |