From 870973197cf23f47edbcbefac7c50006eff3144a Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 7 Jan 2012 11:37:50 +0100 Subject: [PATCH] Only bind images when they weren't (issue #353) --- src/modules/graphics/opengl/Image.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/opengl/Image.cpp b/src/modules/graphics/opengl/Image.cpp index 6be084373..dc2a84f0a 100644 --- a/src/modules/graphics/opengl/Image.cpp +++ b/src/modules/graphics/opengl/Image.cpp @@ -262,8 +262,15 @@ namespace opengl void Image::bind() const { - if (texture != 0) - glBindTexture(GL_TEXTURE_2D,texture); + if (texture == 0) + return; + + GLuint boundTex; + glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&boundTex); + + // only bind if this texture is not already bound + if (boundTex != texture) + glBindTexture(GL_TEXTURE_2D, texture); } bool Image::load()