Thanks again for your reply,
With OpenGL you don't unbind a shader, you bind another one (including a null one).
Wouldn't it then be an option to "unbind" a shader when Shader::bind is called on an empty shader? Currently, as far as I understand the code, nothing is done if bind is called on an uninitialized shader.
My concrete suggestion (if you don't mind) is to alter Shader::bind() in a way so that
ensureGlContext();
and
glUseProgramObjectARB(...)
are either executed before the if-condition is evaluated or in an else branch:
void Shader::bind() const
{
ensureGlContext();
// Enable the program
glCheck(glUseProgramObjectARB(m_shaderProgram));
if (m_shaderProgram)
{
// Bind the textures
bindTextures();
// Bind the current texture
if (m_currentTexture != -1)
glCheck(glUniform1iARB(m_currentTexture, 0));
}
}
This behavior would then be coherent with glUseProgram - at least in my understanding. And it would be of great use for people who use sf::Shader in the way I do it (probably a very small minority though...)
Kind regards,
Sebastian