Browse Source

Hopefully fixed a major bug related to using Shader:send with textures.

Alex Szpakowski 10 years ago
parent
commit
4dc73959a6

+ 0 - 26
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())

+ 0 - 6
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.
 	 *

+ 4 - 4
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<GLuint> 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();