mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-19 01:24:53 -05:00
Skip texture binding when texture setup has failed
RenderStateTextureBindings::setupTextures() ignores the return value of Texture::setupTexture(). When setup fails, the texture is deleted and left without a valid OpenGL id, but applyOpenGL() still calls Texture::bind(), where CVF_ASSERT on the id aborts the application. Skip bindings without a valid texture id and log a render error instead.
This commit is contained in:
@@ -237,6 +237,14 @@ void RenderStateTextureBindings::applyOpenGL(OpenGLContext* oglContext) const
|
||||
const Sampler* sampler = m_bindings[i].sampler.p();
|
||||
CVF_ASSERT(texture && sampler);
|
||||
|
||||
// Texture setup in setupTextures() can fail at run-time, leaving the texture without a valid OpenGL id.
|
||||
// Skip the binding in that case, as Texture::bind() asserts on an invalid id.
|
||||
if (texture->textureOglId() == 0)
|
||||
{
|
||||
CVF_LOG_RENDER_ERROR(oglContext, "Skipping texture binding, texture has not been set up.");
|
||||
continue;
|
||||
}
|
||||
|
||||
cvfGL->glActiveTexture(static_cast<GLenum>(GL_TEXTURE0 + i));
|
||||
|
||||
texture->bind(oglContext);
|
||||
|
||||
Reference in New Issue
Block a user