Been doing a little source diving of the latest snapshot, preparatory to tackling a new project using shaders, and in Graphics/Shader.cpp I found the function SetCurrentTexture:
void Shader::SetCurrentTexture(const std::string& name)
{
if (myShaderProgram)
{
EnsureGlContext();
// Find the location of the variable in the shader
int myCurrentTexture = glGetUniformLocationARB(myShaderProgram, name.c_str());
if (myCurrentTexture == -1)
Err() << "Texture \"" << name << "\" not found in shader" << std::endl;
}
}
This seems a little weird to me, since the declaration int myCurrentTexture appears to shadow the member myCurrentTexture declared as part of Shader class. Thus, the result of the glGetUniformLocationARB call is discarded at the end of the scope, rather than being assigned to the member. Is this intentional? If so, it still seems weird, since no other method in the Shader class assigns to Shader::myCurrentTexture except the constructor, which inits it to -1. Yet the Shader::Bind method checks the value of Shader::myCurrentTexture before calling glUniform1iARB.