From a3aa26bbe49f254c91876a1fb63a3ccf57c09aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 15:01:03 +0200 Subject: [PATCH] Proper state tracking also in texture-multi-bind. --- src/Magnum/AbstractTexture.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index d5f1e7256..f4e31d568 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -172,13 +172,21 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, std: /* Create array of IDs and also update bindings in state tracker */ Containers::Array ids{textures.size()}; Int i{}; + bool different = false; for(AbstractTexture* const texture: textures) { if(texture) texture->createIfNotAlready(); - textureState->bindings[firstTextureUnit + i].second = ids[i] = texture ? texture->_id : 0; + + const GLuint id = ids[i] = texture ? texture->_id : 0; + if(textureState->bindings[firstTextureUnit + i].second != id) { + different = true; + textureState->bindings[firstTextureUnit + i].second = id; + } + ++i; } - glBindTextures(firstTextureUnit, ids.size(), ids); + /* Avoid doing the binding if there is nothing different */ + if(different) glBindTextures(firstTextureUnit, ids.size(), ids); } #endif