In the following block of code:
void gui::Button::draw(sf::RenderTarget& target, sf::RenderStates states)const
{
states.shader = &stateShader;
if (!arePredicatesFulfilled()) states.shader->setParameter("buttonState", Unavailable);
// draw statements....
}
Where stateShader is a member of class Button, the compiler won't let me change the parameter of the shader, giving me an error reading: "error C2663: 'sf::Shader::setParameter' : 10 overloads have no legal conversion for 'this' pointer."
As far as I am aware, this is happening because of the fact that draw() is a const function and, as such, 'this' is a const pointer in it. Why does that, however, stop me from changing things in states, a non-const object?
I also tried instantiating a shader in the draw function instead of using the (const) one in class Button, still didn't allow me to change the parameter.