There's a possible implementation of this that could bring another useful feature to sf::Shader: resolving uniform locations in advance rather than on first call to setUniform.
Here is a draft to show the idea:
struct UniformLocation
{
UniformLocation(std::string name);
std::string name;
int index;
bool resolved;
};
UniformLocation Shader::getUniformLocation(std::string name)
{
// glUniformLocation
}
Shader::setUniform(UniformLocation location, xxx value)
{
// use location.index if already resolved,
// or resolve location.name otherwise (old behaviour)
}
Thanks to the implicit constructor of
UniformLocation, we don't break the previous API (ie. we can still call
shader.setUniform("name", value)).
Note that we can still use the internal cache, or remove it since now user has explicit control on uniform location resolution.