SFML community forums

Help => Graphics => Topic started by: sponsz on November 02, 2010, 02:28:19 pm

Title: sf:shape setup overhead?
Post by: sponsz on November 02, 2010, 02:28:19 pm
Hi gents,

How much overhead if any is inherent in shape definition?

In other words is it better to set up my shapes in an initialization phase before the main update loop?

In simpleshapes.cpp we have this code:

sf::Shape Polygon;
Polygon.AddPoint(0, -50,  sf::Color(255, 0, 0),     sf::Color(0, 128, 128));
...

So we're defining a Shape variable and then adding points to it.  This is done every tick.
Is it set up this way just for clarity?  Would it be faster to do this in the init phase and then simply do

App.Draw(Polygon);

every tick?

It's been a few months since I worked with SFML and I seem to remember that it was quite fast for my purposes but I didn't quite have the insane speed from it that I expected and I'm wondering now if I was running into setup overhead.

Thanks!
Title: sf:shape setup overhead?
Post by: Laurent on November 02, 2010, 02:39:10 pm
Sure you can get slightly better performances if you don't create the shapes every tick. It depends how many shapes you have, and how many points they have, but I don't think this is really noticeable.

You won't know for sure until you test it.
Title: sf:shape setup overhead?
Post by: sponsz on November 03, 2010, 04:16:18 pm
Thanks Laurent.  As always great job with the library, it's the best thing I've found for my needs and that includes a number of commercial graphics libraries.