aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-11-07 11:08:49 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-07 19:13:30 +0100
commit734f424ee97fc74027f2717c592c0b329e41573b (patch)
tree8eada28320d34ba313931de7bbca8cb411effd74
parentc29e825ec6064aa266f0082b3d3b1cb0ceb0809a (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>
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp19
-rw-r--r--src/quick/items/qquickshadereffectsource_p.h2
2 files changed, 19 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()
diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h
index 85b58e67e4..6218775700 100644
--- a/src/quick/items/qquickshadereffectsource_p.h
+++ b/src/quick/items/qquickshadereffectsource_p.h
@@ -139,6 +139,8 @@ private:
QOpenGLFramebufferObject *m_secondaryFbo;
QSharedPointer<QSGDepthStencilBuffer> m_depthStencilBuffer;
+ GLuint m_transparentTexture;
+
#ifdef QSG_DEBUG_FBO_OVERLAY
QSGSimpleRectNode *m_debugOverlay;
#endif