Browse Source

Fix the active GL texture unit not always being set properly.

Fixes issues where texture methods wouldn't have any effect, depending on the current internal opengl state.
Alex Szpakowski 5 years ago
parent
commit
9c2454816f
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/modules/graphics/opengl/OpenGL.cpp

+ 5 - 0
src/modules/graphics/opengl/OpenGL.cpp

@@ -993,6 +993,11 @@ void OpenGL::bindTextureToUnit(TextureType target, GLuint texture, int textureun
 		else
 		else
 			state.curTextureUnit = textureunit;
 			state.curTextureUnit = textureunit;
 	}
 	}
+	else if (!restoreprev && textureunit != state.curTextureUnit)
+	{
+		glActiveTexture(GL_TEXTURE0 + textureunit);
+		state.curTextureUnit = textureunit;
+	}
 }
 }
 
 
 void OpenGL::bindTextureToUnit(Texture *texture, int textureunit, bool restoreprev)
 void OpenGL::bindTextureToUnit(Texture *texture, int textureunit, bool restoreprev)