tl;dr - I think I found a bug in the new Shader API.
Hi all,
I'm having a little trouble passing a Vec4 color into my shader using the new shader API on 2.4. The documentation suggests that a sf::Color can be converted to a sf::Glsl::Vec4 to be passed into the setUniform method, but I can't get that to happen.
I define my color:
const sf::Color outlineColor = sf::Color::Red;
And then I try the following, which result in the following errors:
shader.setUniform("outlineColor", outlineColor);
Parameter type mismatch: Types 'float' and 'const sf::Color' are not compatible
shader.setUniform("outlineColor", sf::Glsl::Vec4(outlineColor));
Too many arguments, expected 0
I've also tried setting it to a variable first:
sf::Glsl::Vec4 color = outlineColor;
Class 'const sf::Color' is not compatible with class 'sf::Glsl::Vec4'
Thinking maybe it was because my color was const, I tried removing that to no effect. I tried passing a reference:
shader.setUniform("outlineColor", &outlineColor);
But then I get a warning saying: "Parameter type mismatch: Taking boolean from pointer 'sf::Color *' without a cast"
Yet the documentation for setUniform clearly states this should work:
/// This overload can also be called with sf::Color objects
/// that are converted to sf::Glsl::Vec4.
The documentation for Vec4 even says it:
/// sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f);
/// sf::Glsl::Vec4 color = sf::Color::Cyan;
But having tried both of those, I get errors.
This being my first venture into C++ in many years (I work mostly in C# and Java these days), maybe I'm just missing something. Is there some other way I should be going about causing this conversion, or is this a bug in the new Shader API? I wanted to ask here first before creating an issue on GitHub just in case I'm missing some really obvious step. For now I've resorted to calling the old setParameter method which takes an sf::Color directly, but that causes big ugly errors in my output (rightly so, it's deprecated).
Thanks for the help.