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

Author Topic: Why is VertexArray.myVertices private?  (Read 1453 times)

0 Members and 1 Guest are viewing this topic.

ChonDee

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Why is VertexArray.myVertices private?
« on: February 17, 2012, 10:11:08 pm »
I am wondering why is the myVertices vector private in VertexArray?
It would be helpful if I could loop through it and perform operations on individual vertices, remove them one by one instead of clearing all, etc.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Why is VertexArray.myVertices private?
« Reply #1 on: February 17, 2012, 10:14:29 pm »
If sf::VertexArray is not good for you then don't use it, take a std::vector<sf::Vertex> instead. There's no magic in sf::VertexArray, it's just a thin wrapper around std::vector<sf::Vertex> provided for convenience.
Laurent Gomila - SFML developer

ChonDee

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Why is VertexArray.myVertices private?
« Reply #2 on: February 18, 2012, 09:29:54 am »
Quote from: "Laurent"
If sf::VertexArray is not good for you then don't use it, take a std::vector<sf::Vertex> instead. There's no magic in sf::VertexArray, it's just a thin wrapper around std::vector<sf::Vertex> provided for convenience.


Thanks for your reply,

Sorry, didn't want to sound like I'm complaining, it's not like it is not good for me, it really improved the performance of drawing lots of particles. It is just currently I have to have a vector of vertices where I can manipulate each of them, end every frame I have to clear the VertexArray and copy each vertex to it.

I thought I was missing something, and there was some other way around this.  

Anyways, I'll keep it the way it is for now, maybe later I'll rewrite it based on your code but with the vector public.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Why is VertexArray.myVertices private?
« Reply #3 on: February 18, 2012, 10:31:33 am »
Quote
Sorry, didn't want to sound like I'm complaining

You didn't, I just wanted to emphasize the fact that sf::VertexArray is just a convenience wrapper and that you're not forced to use it at all if its API is too restrictive for you ;)

Quote
every frame I have to clear the VertexArray and copy each vertex to it

No no, don't use VertexArray at all, use the Draw overload that takes an array of vertices directly:
Code: [Select]
window.Draw(&your_vector[0], your_vector.size(), sf::Quads);
Laurent Gomila - SFML developer

ChonDee

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Why is VertexArray.myVertices private?
« Reply #4 on: February 18, 2012, 08:15:44 pm »
Quote
No no, don't use VertexArray at all, use the Draw overload that takes an array of vertices directly:
Code: [Select]
window.Draw(&your_vector[0], your_vector.size(), sf::Quads);


Thank you, I wasn't aware you can do that