SFML community forums
Help => Graphics => Topic started by: nimn 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?
-
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 (https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Sprite.cpp#L88), it's simple to read and often gives you the solution without having to read the doc or to ask on the forum.
-
got it working - thanks for the help!
-
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
-
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).