61
Feature requests / Getting a sprite's vertices
« on: December 19, 2013, 11:56:10 pm »
It is known that the need to draw sprites individually hurts performance and that one should prefer vertex arrays to that end. It is then a shame that sf::Sprite's internal vertices cannot be accessed.
What I 've found myself doing too often is making a class holding an array of four sf::Vertex, that can be appended to a VertexArray or similar container when it is time to draw. Often, this class will also need a getBounds method, setters for the texture rect and so on, making it similar to a sf::Sprite.
I would propose then that there is a way to use sf::Sprite for this purpose; either
a) sf::Sprite::getVertices() that returns an array of the 4 vertices or
b) sf::Sprite::appendTo() taking as parameter either
i) a sf::VertexArray
ii) an output iterator, to accomodate the user's container of sf::Vertex.
What I 've found myself doing too often is making a class holding an array of four sf::Vertex, that can be appended to a VertexArray or similar container when it is time to draw. Often, this class will also need a getBounds method, setters for the texture rect and so on, making it similar to a sf::Sprite.
I would propose then that there is a way to use sf::Sprite for this purpose; either
a) sf::Sprite::getVertices() that returns an array of the 4 vertices or
b) sf::Sprite::appendTo() taking as parameter either
i) a sf::VertexArray
ii) an output iterator, to accomodate the user's container of sf::Vertex.