diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index b0b7bc838..16fab954c 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -68,6 +68,7 @@ class NAZARA_API NzOpenGL static void BindBuffer(nzBufferType type, GLuint id); static void BindProgram(GLuint id); static void BindTexture(nzImageType type, GLuint id); + static void BindTexture(unsigned int textureUnit, nzImageType type, GLuint id); static void DeleteBuffer(nzBufferType type, GLuint id); static void DeleteProgram(GLuint id); diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 8e3734268..d5810dbca 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -141,6 +141,17 @@ void NzOpenGL::BindTexture(nzImageType type, GLuint id) } } +void NzOpenGL::BindTexture(unsigned int textureUnit, nzImageType type, GLuint id) +{ + if (s_texturesBinding[textureUnit] != id) + { + SetTextureUnit(textureUnit); + + glBindTexture(TextureTarget[type], id); + s_texturesBinding[textureUnit] = id; + } +} + void NzOpenGL::DeleteBuffer(nzBufferType type, GLuint id) { glDeleteBuffers(1, &id); @@ -158,8 +169,12 @@ void NzOpenGL::DeleteProgram(GLuint id) void NzOpenGL::DeleteTexture(GLuint id) { glDeleteTextures(1, &id); - if (s_texturesBinding[s_textureUnit] == id) - s_texturesBinding[s_textureUnit] = 0; + + for (GLuint& binding : s_texturesBinding) + { + if (binding == id) + binding = 0; + } } GLuint NzOpenGL::GetCurrentBuffer(nzBufferType type)