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

Author Topic: Drawing a sf::VertexArray with some default constructed Vertices  (Read 2829 times)

0 Members and 1 Guest are viewing this topic.

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
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!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Drawing a sf::VertexArray with some default constructed Vertices
« Reply #1 on: March 22, 2019, 09:38:13 am »
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.
Laurent Gomila - SFML developer

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Drawing a sf::VertexArray with some default constructed Vertices
« Reply #2 on: March 22, 2019, 10:17:42 am »
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.
« Last Edit: March 22, 2019, 10:19:13 am by degski »

Hapax

  • Hero Member
  • *****
  • Posts: 3383
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Drawing a sf::VertexArray with some default constructed Vertices
« Reply #3 on: March 23, 2019, 10:20:42 pm »
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).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Drawing a sf::VertexArray with some default constructed Vertices
« Reply #4 on: March 25, 2019, 09:47:18 am »
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). 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Drawing a sf::VertexArray with some default constructed Vertices
« Reply #5 on: March 25, 2019, 10:11:30 am »
If a quad with all default-constructed vertices should appear as a white point at coordinates (0, 0).
Laurent Gomila - SFML developer

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Drawing a sf::VertexArray with some default constructed Vertices
« Reply #6 on: March 25, 2019, 11:55:40 am »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Drawing a sf::VertexArray with some default constructed Vertices
« Reply #7 on: March 25, 2019, 01:42:04 pm »
I assumed that a quad with no area would appear as a point, but no output at all is also a possibility I guess.
Laurent Gomila - SFML developer

 

anything