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