SFML community forums

Help => Graphics => Topic started by: Daid on November 01, 2016, 11:28:58 am

Title: sf::Shader::setUniform with bool parameter -> bug source?
Post by: Daid on November 01, 2016, 11:28:58 am
First off, let me say I love the improvements in SFML 2.4.0, nice upgrade compared to 2.3.x on the shader interface.

However, I just spend half an hour trying to find out why my shader was not rendering with a texture. I finally found out that I was passing an sf::Texture pointer instead of a reference to the setUniform function. And, as C++ does implicit type conversions of pointers to booleans, it was calling the setUniform(name, bool) instead.

With all the new setUniform functions, maybe setUniform(name, bool) is a bit out of place due to the very easy mistake of implicit pointer casts of all the other objects you can pass as parameters to this function.


Possible ways to prevent this problem are:


(I know I should prefer references. But that is not always a possibility in this case)

EDIT: I just realized. This is also inconsistent with the sf::Texture::bind API, which uses a sf::Texture pointer instead of a reference.