Thanks in advance, the point is the next. I have making a little particle engine, the problem come when i tried to optimize it using a vertexarray to render it. The first implementation, using sf::Sprites, could render 10K particles without problem in my machine, but when I have changed to a sf::VertexArray implementation the render process become slower, it cannot mantain the framerate with 3K particles. What Could I be doing wrong?.
One thing more, I belive noticed the problem is in the RenderWindow::draw call because I have monitoring the program with and without this call. I let you some code snippet. Thanks again.
void System::draw (sf::RenderWindow& theWindow)
{
mVertices.clear();
std::list<Particle>::const_iterator it;
for(it = mParticles.begin();it != mParticles.end();it++)
{
sf::Transform anTransform;
anTransform.translate(it->getPosition().x,it->getPosition().y);
anTransform.rotate(it->getAngle());
anTransform.scale(it->getScale().x,it->getScale().y);
sf::Rect<int> anTexRect = it->getTexRect();
sf::Vector2f anPositions[4];
anPositions[0] = anTransform.transformPoint(sf::Vector2f(-(anTexRect.width / 2),-(anTexRect.height /2)));
anPositions[1] = anTransform.transformPoint(sf::Vector2f( (anTexRect.width / 2),-(anTexRect.height /2)));
anPositions[2] = anTransform.transformPoint(sf::Vector2f( (anTexRect.width / 2), (anTexRect.height /2)));
anPositions[3] = anTransform.transformPoint(sf::Vector2f(-(anTexRect.width / 2), (anTexRect.height /2)));
sf::Vector2f anTexCoords[4];
anTexCoords[0] = sf::Vector2f(anTexRect.left, anTexRect.top);
anTexCoords[1] = sf::Vector2f(anTexRect.left + anTexRect.width, anTexRect.top);
anTexCoords[2] = sf::Vector2f(anTexRect.left + anTexRect.width, anTexRect.top + anTexRect.height);
anTexCoords[3] = sf::Vector2f(anTexRect.left, anTexRect.top + anTexRect.height);
for (int i = 0; i < 4;i++)
{
mVertices.append(sf::Vertex(anPositions[i], sf::Color(255, 255, 255, 255),anTexCoords[i]));
}
theWindow.draw(mVertices,mStates);
}