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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Sub

Pages: 1 [2]
16
Graphics / Drawing lines is incredibly slow?
« on: September 25, 2012, 02:54:08 am »
I'm currently trying to replicate this tutorial [http://gamedev.tutsplus.com/tutorials/implementation/simulate-fabric-and-ragdolls-with-simple-verlet-integration/] and I'm getting low FPS when I try to draw a grid. 

I have 2500 points on screen, each spaced 6 pixels apart from each other, and I want to draw a line between each point and its neighbor.  When I do so, my FPS goes from 4200 to 20-100.  Is this normal, or am I doing something wrong?

Here's the code I'm using to draw the lines.
void SFML_Program::drawLine(sf::Vector2f a, sf::Vector2f b)
{
        sf::Vertex line[2] = {a, b};
        MainWindow.draw(line, 2, sf::Lines);
}

I've also tried:
        void SFML_Program::drawLine(sf::Vector2f a, sf::Vector2f b)
{
        sf::VertexArray lines(sf::Lines, 2);
        lines[0].position = a;
        lines[1].position = b;
       
        MainWindow.draw(lines);
}

I'm calling that 4900 times to produce this. 

http://i.imgur.com/tI1tz.png

The code that calls it simply retrieves the two points it needs and then calls the drawline.  Am I doing something wrong?

Pages: 1 [2]