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

Author Topic: setFramerateLimit doesn't work  (Read 1943 times)

0 Members and 1 Guest are viewing this topic.

Ocordu

  • Newbie
  • *
  • Posts: 4
    • View Profile
setFramerateLimit doesn't work
« 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;
}
 

Noob

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: setFramerateLimit doesn't work
« Reply #1 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.
Killing goblins at Lumbridge. Windows 7 - 64 bit. AMD Radeon HD 6700. Using VS2012 Express, SFML 2.1 - Static.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: setFramerateLimit doesn't work
« Reply #2 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

Ocordu

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: setFramerateLimit doesn't work
« Reply #3 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  :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: setFramerateLimit doesn't work
« Reply #4 on: February 09, 2014, 08:16:32 pm »
Laurent Gomila - SFML developer