SFML community forums

Help => General => Topic started by: Ocordu on February 09, 2014, 07:07:44 pm

Title: setFramerateLimit doesn't work
Post by: Ocordu on February 09, 2014, 07:07:44 pm
My application uses a large amount of CPU regardless of if it's set or not.

#include <SFML/Graphics.hpp>

int main() {
    sf::RenderWindow game(sf::VideoMode(800, 450), "Survive++");
    game.setFramerateLimit(60);
    while (game.isOpen()) {
        sf::Event event;
        while (game.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                game.close();
            }
        }
    }
    return 0;
}
 
Title: Re: setFramerateLimit doesn't work
Post by: Noob on February 09, 2014, 07:27:29 pm
Frame rate and update rate are different. Your computer will try and run the program as fast as possible, so you need a way of regulating the speed, otherwise your program will actually run at different speeds on different computers, which is generally bad.

Apart from that there could be a bunch of reasons. 'large' is relative, the program might be running just fine but could appear to be intensive if you have a weak CPU.
Title: Re: setFramerateLimit doesn't work
Post by: G. on February 09, 2014, 07:44:58 pm
Try at least with a call to game.display()

[edit]oops, didn't see it was a double post...: http://en.sfml-dev.org/forums/index.php?topic=14364
Title: Re: setFramerateLimit doesn't work
Post by: Ocordu on February 09, 2014, 07:50:05 pm
Try at least with a call to game.display()

[edit]oops, didn't see it was a double post...: http://en.sfml-dev.org/forums/index.php?topic=14364

Thanks  :)
Title: Re: setFramerateLimit doesn't work
Post by: Laurent on February 09, 2014, 08:16:32 pm
Double-post.

http://en.sfml-dev.org/forums/index.php?topic=14364.0