mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Hopefully fixed a major bug related to using Shader:send with textures.
This commit is contained in:
@@ -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)
|
void OpenGL::bindTextureToUnit(GLuint texture, int textureunit, bool restoreprev)
|
||||||
{
|
{
|
||||||
if (textureunit < 0 || (size_t) textureunit >= state.boundTextures.size())
|
if (textureunit < 0 || (size_t) textureunit >= state.boundTextures.size())
|
||||||
|
|||||||
@@ -261,12 +261,6 @@ public:
|
|||||||
**/
|
**/
|
||||||
void bindTexture(GLuint texture);
|
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.
|
* Helper for binding a texture to a specific texture unit.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ Shader::Shader(const ShaderSource &source)
|
|||||||
throw love::Exception("Cannot create shader: no source code!");
|
throw love::Exception("Cannot create shader: no source code!");
|
||||||
|
|
||||||
// initialize global texture id counters if needed
|
// initialize global texture id counters if needed
|
||||||
if ((int) textureCounters.size() < gl.getMaxTextureUnits())
|
if ((int) textureCounters.size() < gl.getMaxTextureUnits() - 1)
|
||||||
textureCounters.resize(gl.getMaxTextureUnits(), 0);
|
textureCounters.resize(gl.getMaxTextureUnits() - 1, 0);
|
||||||
|
|
||||||
// load shader source and create program object
|
// load shader source and create program object
|
||||||
loadVolatile();
|
loadVolatile();
|
||||||
@@ -216,7 +216,7 @@ bool Shader::loadVolatile()
|
|||||||
|
|
||||||
// zero out active texture list
|
// zero out active texture list
|
||||||
activeTexUnits.clear();
|
activeTexUnits.clear();
|
||||||
activeTexUnits.insert(activeTexUnits.begin(), gl.getMaxTextureUnits(), 0);
|
activeTexUnits.insert(activeTexUnits.begin(), gl.getMaxTextureUnits() - 1, 0);
|
||||||
|
|
||||||
std::vector<GLuint> shaderids;
|
std::vector<GLuint> shaderids;
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ void Shader::unloadVolatile()
|
|||||||
|
|
||||||
// active texture list is probably invalid, clear it
|
// active texture list is probably invalid, clear it
|
||||||
activeTexUnits.clear();
|
activeTexUnits.clear();
|
||||||
activeTexUnits.resize(gl.getMaxTextureUnits(), 0);
|
activeTexUnits.resize(gl.getMaxTextureUnits() - 1, 0);
|
||||||
|
|
||||||
// same with uniform location list
|
// same with uniform location list
|
||||||
uniforms.clear();
|
uniforms.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user