diff options
author | Mauro Persano <mauro.persano@kdab.com> | 2017-08-28 22:08:57 -0300 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-08-31 12:15:16 +0000 |
commit | 2e4acacfa3a062b8585226500f6cbc65597b8b67 (patch) | |
tree | 51d64ac916b4040c332018140619b2a081e2b17c | |
parent | 7a89913cea6c471cefdb3d0cbd32583ea1b6d494 (diff) |
Don't create GL textures when format is not set
For textures where the format was not set (this may happen, for
instance, for a Texture2D without TextureImage children), don't try to
create a GL texture or the underlying OpenGL calls will fail. Also avoid
trying to set the corresponding uniform while rendering.
Change-Id: I17d95e2a2f1f1a1e5c22a0296c8641c4873e9e7f
Task-Id: QTBUG-62654
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/render/graphicshelpers/graphicscontext.cpp | 9 | ||||
-rw-r--r-- | src/render/texture/gltexture.cpp | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp index 1eda79e94..e7f8af71c 100644 --- a/src/render/graphicshelpers/graphicscontext.cpp +++ b/src/render/graphicshelpers/graphicscontext.cpp @@ -1239,7 +1239,14 @@ void GraphicsContext::setParameters(ShaderParameterPack ¶meterPack) for (const ShaderUniform &uniform : activeUniforms) { // We can use [] as we are sure the the uniform wouldn't // be un activeUniforms if there wasn't a matching value - applyUniform(uniform, values[uniform.m_nameId]); + const auto &v = values[uniform.m_nameId]; + + // skip invalid textures + if (v.valueType() == UniformValue::TextureValue && + v.constData<UniformValue::Texture>()->textureId == -1) + continue; + + applyUniform(uniform, v); } } diff --git a/src/render/texture/gltexture.cpp b/src/render/texture/gltexture.cpp index 606681bd5..0df596ec2 100644 --- a/src/render/texture/gltexture.cpp +++ b/src/render/texture/gltexture.cpp @@ -177,6 +177,10 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture() } } + // don't try to create the texture if the format was not set + if (m_properties.format == QAbstractTexture::Automatic) + return nullptr; + if (texturedDataInvalid) return nullptr; |