I've been getting really low framerates (10 fps) when drawing around 2000 sf::RectangleShapes alternating with 2000 sf::Sprites, which are all sized 8px X 12px. The drawable objects are contained in a class extending sf::Drawable and sf::Transform, with a very simple draw overload, which basically looks like this:
{
states.transform *= getTransform();
for(//... iterate through list
{
target.draw(rectangle, states);
target.draw(sprite,states);
}
}
After profiling I've noticed that that a huge amount of time is spent in sf::Transform::getInverse and new and delete calls made from sf::Transform::getInverse, which are found right after this draw call in the call stack. After looking through the SFML source code on GitHub for quite some time I haven't been able to find where this code calls getInverse().
If I comment out the calls to draw rectangles, the fps jumps up to over 200, while if I do the same for the sprites it only goes up to about 40 fps. With both removed it stays well over 500 fps.
Is there a problem with the way I am drawing these rectangles and sprites or does the problem lie elsewhere?