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

Author Topic: .setColor and vertex arrays?  (Read 3444 times)

0 Members and 1 Guest are viewing this topic.

nimn

  • Newbie
  • *
  • Posts: 13
    • View Profile
.setColor and vertex arrays?
« on: December 27, 2017, 08:31:52 am »
hello,

quick question on vertex arrays and transforms.
I see in sprites there is a set color function allowing tinting as well as opacity changes
However, I do not see it, or how it would be implemented with vertex arrays

I've been all over the tutorials, docs and google - any help?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: .setColor and vertex arrays?
« Reply #1 on: December 27, 2017, 09:20:52 am »
A vertex array is an array of sf::Vertex. And sf::Vertex has a "color" member. So all you have to do is to iterate and change it.

And don't hesitate to have a look at the implementation, it's simple to read and often gives you the solution without having to read the doc or to ask on the forum.
« Last Edit: December 27, 2017, 09:22:36 am by Laurent »
Laurent Gomila - SFML developer

nimn

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: .setColor and vertex arrays?
« Reply #2 on: January 03, 2018, 12:45:20 pm »
got it working - thanks for the help!

nimn

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: .setColor and vertex arrays?
« Reply #3 on: January 03, 2018, 01:13:00 pm »
ok sorry - follow up question...

So the tinting works pretty well in manipulating colors, however, I can't get white with a tint as far as I see.
Is white possible with a colored (non-white) texture? any tricks?

thanks again

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: .setColor and vertex arrays?
« Reply #4 on: January 03, 2018, 02:19:10 pm »
No. Vertex color and texture color are multiplied to produce the final pixel; and the only way to get white is to multiply white and white together.

You'll have to find a more complicated solution (most likely involving blending modes or shaders).
Laurent Gomila - SFML developer