SFML community forums
Help => Graphics => Topic started by: battosaijenkins on May 29, 2020, 08:10:31 pm
-
Hello, I posted a question in github SFML Gradient shaders but was told to post here instead. I was wondering if it's possible to pass an sf::Transform into the draw function along with the shader?
For example normal draw I would pass a transform like:
window.draw(circle, transform);
but with shaders that 2nd parameter is already taken up like
window.draw(circle, &shader);
and I cant add a third parameter. I read somewhere that I could use
shader.setUniform("matrix", sf::Glsl::Mat4(transform));
but I added
"uniform mat4 matrix;"
in const char RadialGradient[] but I'm getting Uniform "matrix" not found in shader. Am I doing it wrong, or overdoing it or missing something?
-
Hey. You can use an sf::RenderStates (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1RenderStates.php) and pass it to your draw function instead of only the shader.
-
So I cant use sf::Transform?
-
Oh I see what you mean. You're saying I would use sf::RenderStates state and then use state.transform = transform and also use &shader in state.shader then pass state like window.draw(circle, state);? I think I understand now, thanks.