From 9c2454816f1933744e06c373f3b151bb53f69f9e Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 15 Mar 2020 01:29:33 -0300 Subject: [PATCH] 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. --- src/modules/graphics/opengl/OpenGL.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 24a2776b2..83d2fe911 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -993,6 +993,11 @@ void OpenGL::bindTextureToUnit(TextureType target, GLuint texture, int textureun else 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)