Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfml gradient shaders question  (Read 2630 times)

0 Members and 1 Guest are viewing this topic.

battosaijenkins

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
sfml gradient shaders question
« 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:

Code: [Select]
window.draw(circle, transform);

but with shaders that 2nd parameter is already taken up like

Code: [Select]
window.draw(circle, &shader);

 and I cant add a third parameter. I read somewhere that I could use

Code: [Select]
shader.setUniform("matrix", sf::Glsl::Mat4(transform));

but I added

Code: [Select]
"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?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: sfml gradient shaders question
« Reply #1 on: May 29, 2020, 08:56:04 pm »
Hey. You can use an sf::RenderStates and pass it to your draw function instead of only the shader.

battosaijenkins

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: sfml gradient shaders question
« Reply #2 on: May 30, 2020, 02:22:46 am »
So I cant use sf::Transform?

battosaijenkins

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: sfml gradient shaders question
« Reply #3 on: May 30, 2020, 03:01:25 am »
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.

 

anything