SFML community forums

Help => Graphics => Topic started by: Rob92 on February 16, 2016, 02:12:53 am

Title: How to add a range of vertices to a sf::VertexArray?
Post by: Rob92 on February 16, 2016, 02:12:53 am
I was wondering if it is possible to add more than 1 vertex at a time to an sf::VertexArray.
At the moment I use the append function but I thought that I might be able to increase performance by adding multiple vertices at once. Is that possible without modifying the source code?
Title: Re: How to add a range of vertices to a sf::VertexArray?
Post by: Hapax on February 16, 2016, 03:14:21 am
You can set the number of vertices in a vertex array during construction (http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1VertexArray.php#a4bb1c29a0e3354a035075899d84f02f9):
sf::VertexArray vertexArray(sf::Points, 100); // 100 vertices
and/or you can resize (http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1VertexArray.php#a0c0fe239e8f9a54e64d3bbc96bf548c0) it later:
vertexArray.resize(200); // now 200 vertices
Title: Re: How to add a range of vertices to a sf::VertexArray?
Post by: Laurent on February 16, 2016, 09:31:08 am
If you need maximum performances then you'd better use a std::vector<sf::Vertex> directly. sf::VertexArray is just a convenience wrapper, which offers a limited interface to std::vector operations.
Title: Re: How to add a range of vertices to a sf::VertexArray?
Post by: Rob92 on February 16, 2016, 01:15:24 pm
Thanks, ill try using a vector