SFML community forums
Help => Graphics => Topic started by: degski on March 22, 2019, 08:17:56 am
-
A simple quick question [I hope].
Does drawing default constructed Vertices [in a sf::VertexArray] constitute UB and/or does it cause any other trouble?
Doing this appears to not create any problems (Debug or Release), but I just want to be sure!
-
Why would it be a UB? sf::Vertex is a very simple structure; a default constructed vertex is just an instance with some predefined values for position, color and texture coordinates. And since sf::Vertex has default constructor explicitly defined, those values are well defined and known.
-
I understand, there are no allocations or whatever (they're POD's basically), but I am drawing them, for some animation I will set them to some values later and then when the animation is finished, I will reset (memset) them again. The objective is to keep everything in one sf::VertexArray.
-
Be aware that if you're drawing all of the vertices including the ones that are still in their default state, the shape may not be as expected as those vertices will 'pull' the shape to (0, 0).
-
Be aware that if you're drawing all of the vertices including the ones that are still in their default state, the shape may not be as expected as those vertices will 'pull' the shape to (0, 0).
I am drawing textured quads with the VertexArray, either a quad is proper (i.e. it's got position, color and texture coords) or it is completely default (all 4 vertices of a particular quad).
I hope(d) that that doesn't create any funny stuff (please comment if you have doubts over this).
-
If a quad with all default-constructed vertices should appear as a white point at coordinates (0, 0).
-
If a quad with all default-constructed vertices should appear as a white point at coordinates (0, 0).
Thanks Laurent. I got my extra strong spectacles out (not kidding) and had a look. I don't see a white pixel (everything is very dark, so it should have been visible easily (with the spectacles on a 1920*1080 display).
Iff I start seeing it [the white pixel] I'm warned, thanks.
-
I assumed that a quad with no area would appear as a point, but no output at all is also a possibility I guess.