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

Author Topic: How to add a range of vertices to a sf::VertexArray?  (Read 1765 times)

0 Members and 1 Guest are viewing this topic.

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
How to add a range of vertices to a sf::VertexArray?
« 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?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How to add a range of vertices to a sf::VertexArray?
« Reply #1 on: February 16, 2016, 03:14:21 am »
You can set the number of vertices in a vertex array during construction:
sf::VertexArray vertexArray(sf::Points, 100); // 100 vertices
and/or you can resize it later:
vertexArray.resize(200); // now 200 vertices
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to add a range of vertices to a sf::VertexArray?
« Reply #2 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.
Laurent Gomila - SFML developer

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: How to add a range of vertices to a sf::VertexArray?
« Reply #3 on: February 16, 2016, 01:15:24 pm »
Thanks, ill try using a vector