From 4dc73959a60c3374c26398950d05eef5dc07b126 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 6 Mar 2015 02:08:33 -0400 Subject: [PATCH] Hopefully fixed a major bug related to using Shader:send with textures. --- src/modules/graphics/opengl/OpenGL.cpp | 26 -------------------------- src/modules/graphics/opengl/OpenGL.h | 6 ------ src/modules/graphics/opengl/Shader.cpp | 8 ++++---- 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index facdf8b13..869ed95e2 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -484,32 +484,6 @@ void OpenGL::bindTexture(GLuint texture) } } -void OpenGL::bindTextures(GLuint first, GLsizei count, const GLuint *textures) -{ - if (first + count > (GLuint) maxTextureUnits) - return; - - if (GLAD_VERSION_4_4 || GLAD_ARB_multi_bind) - glBindTextures(first, count, textures); - else - { - for (GLint i = 0; i < count; i++) - { - GLuint texture = textures != nullptr ? textures[i] : 0; - - if (state.boundTextures[first + i] != texture) - { - glActiveTexture(GL_TEXTURE0 + first + i); - glBindTexture(GL_TEXTURE_2D, texture); - - state.boundTextures[first + i] = texture; - } - } - - glActiveTexture(GL_TEXTURE0 + state.curTextureUnit); - } -} - void OpenGL::bindTextureToUnit(GLuint texture, int textureunit, bool restoreprev) { if (textureunit < 0 || (size_t) textureunit >= state.boundTextures.size()) diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index 676324f83..cc64851d0 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -261,12 +261,6 @@ public: **/ void bindTexture(GLuint texture); - /** - * Binds multiple textures to texture units without changing the active - * texture unit. Equivalent to glBindTextures. - **/ - void bindTextures(GLuint first, GLsizei count, const GLuint *textures); - /** * Helper for binding a texture to a specific texture unit. * diff --git a/src/modules/graphics/opengl/Shader.cpp b/src/modules/graphics/opengl/Shader.cpp index c3d296aa6..d87e4c5af 100644 --- a/src/modules/graphics/opengl/Shader.cpp +++ b/src/modules/graphics/opengl/Shader.cpp @@ -80,8 +80,8 @@ Shader::Shader(const ShaderSource &source) throw love::Exception("Cannot create shader: no source code!"); // initialize global texture id counters if needed - if ((int) textureCounters.size() < gl.getMaxTextureUnits()) - textureCounters.resize(gl.getMaxTextureUnits(), 0); + if ((int) textureCounters.size() < gl.getMaxTextureUnits() - 1) + textureCounters.resize(gl.getMaxTextureUnits() - 1, 0); // load shader source and create program object loadVolatile(); @@ -216,7 +216,7 @@ bool Shader::loadVolatile() // zero out active texture list activeTexUnits.clear(); - activeTexUnits.insert(activeTexUnits.begin(), gl.getMaxTextureUnits(), 0); + activeTexUnits.insert(activeTexUnits.begin(), gl.getMaxTextureUnits() - 1, 0); std::vector shaderids; @@ -320,7 +320,7 @@ void Shader::unloadVolatile() // active texture list is probably invalid, clear it activeTexUnits.clear(); - activeTexUnits.resize(gl.getMaxTextureUnits(), 0); + activeTexUnits.resize(gl.getMaxTextureUnits() - 1, 0); // same with uniform location list uniforms.clear();