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

Author Topic: sf:shape setup overhead?  (Read 2405 times)

0 Members and 1 Guest are viewing this topic.

sponsz

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf:shape setup overhead?
« 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!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf:shape setup overhead?
« Reply #1 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.
Laurent Gomila - SFML developer

sponsz

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf:shape setup overhead?
« Reply #2 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.

 

anything