Selaa lähdekoodia

Only bind images when they weren't (issue #353)

Bart van Strien 13 vuotta sitten
vanhempi
commit
870973197c
1 muutettua tiedostoa jossa 9 lisäystä ja 2 poistoa
  1. 9 2
      src/modules/graphics/opengl/Image.cpp

+ 9 - 2
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()