1
Graphics / Re: [SOLVED] [sf::VertexArray VS std::vector] Strange behaviour
« on: May 14, 2012, 10:07:01 pm »
In fact I still don't understand something.
From what I understand, you advise me to 2 arrays in my Fenetre class : the VertexArray, which will be displayed by the RenderWindow, and a vector of Particles, where my Particle class would look like :
But isn't it sad to be obliged to have 2 arrays ? Plus the correspondence between the Vertex and the Particle is only made by its position in the arrays, like :
What if I want to make my arrays dynamic ? And this isn't very secure, if vertexArray contains less elements than particles...
From what I understand, you advise me to 2 arrays in my Fenetre class : the VertexArray, which will be displayed by the RenderWindow, and a vector of Particles, where my Particle class would look like :
Code: [Select]
class Particle {
public :
void update(sf::Vertex &vertex);
// Constructor etc...
private :
sf::Vector2f v;
// All the other members I would need to perform a nice animation...
}
But isn't it sad to be obliged to have 2 arrays ? Plus the correspondence between the Vertex and the Particle is only made by its position in the arrays, like :
Code: [Select]
Fenettre::update() {
for (int i = 0; i < particles.size(); ++i) {
particles[i].update(vertexArray[i]);
}
}
What if I want to make my arrays dynamic ? And this isn't very secure, if vertexArray contains less elements than particles...