Hi there,
I'm running a very basic SFML app, with two cases. One where I display a sprite, one where I do not.
Here is the FPS between thoses cases:
- Without displaying a sprite: 350 FPS
- When displaying a sprite: 230 FPS
Here are the code sample:
sf::RectangleShape background_;
background_.setSize(sf::Vector2f(1900, 1000));
background_.setFillColor(sf::Color(235, 235, 235));
background_.setOutlineColor(sf::Color::Black);
background_.setOutlineThickness(1);
background_.setPosition(20, 20);
sf::RenderWindow window(sf::VideoMode(1920, 1080, 32), "Title");
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
// Close window : exit
if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
window.close();
}
}
window.clear(sf::Color(150, 150, 150));
// Upon uncommenting this line, I lose about 120 FPS
//window.draw(background_);
window.display();
}
Of course getting from 350 FPS to 230 is acceptable, it still is a high value, but the problem is that when I try to display several hundred of sprites (just sf::Shape, nothing fancy), I get below 25 FPS.
Any idea about what I am doing wrong ?