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

Author Topic: SFML SetFramerateLimit Not Limiting Frame Rate  (Read 6832 times)

0 Members and 1 Guest are viewing this topic.

als

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML SetFramerateLimit Not Limiting Frame Rate
« on: April 03, 2010, 03:23:50 am »
Compiler: Visual C++
OS: Windows 7 Enterprise

For some reason, SetFramerateLimit isn't limiting the frame rate in the app I'm working on, but it works fine for others. The framerate is capped to 60, but mine jumps around at 100-99 and then goes down to 50 sometimes. It actually causes serious issues. For example, if I create many objects on screen, I'll see a heavy performance hit, whereas others report no change.

If you need more information regarding the problem, I'd be happy to oblige.

Thanks.

P.S. I have strong reasons to believe that it is not just a case of "their hardware is more powerful than yours."

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #1 on: April 03, 2010, 10:13:27 am »
Could you show a complete and minimal example that reproduces the problem?
Laurent Gomila - SFML developer

als

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #2 on: April 03, 2010, 04:20:18 pm »
Quote from: "Laurent"
Could you show a complete and minimal example that reproduces the problem?


I have an old video of the app here. If you look in the top left corner it shows the frame rate. Note that it should be capped at 60.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #3 on: April 03, 2010, 04:29:28 pm »
Well, I was talking about source code ;)
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #4 on: April 03, 2010, 04:31:01 pm »
Yes, but it would be more helpful if you posted a short piece of code that shows the mentioned problem.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

als

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #5 on: April 04, 2010, 12:14:17 am »
Here is the app constructor that sets the frame rate limit.

Code: [Select]

App::App(
  const std::string &title,
  Uint width,
  Uint height,
  Uint framerate
)
 : m_window( sf::VideoMode( width, height ), title ),
   m_deltaTime(0.0f),
   m_fps(0.0f) {
m_window.SetFramerateLimit( framerate );
  m_keyManager.Init( m_window.GetInput() );
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #6 on: April 04, 2010, 10:00:05 am »
A complete and minimal example would be more helpful ;)
Laurent Gomila - SFML developer

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #7 on: April 04, 2010, 02:55:44 pm »
Quote from: "als"


HAHA, Kickle Cubicle, sweet old NES memories. :')

als

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #8 on: April 05, 2010, 12:41:17 am »
Quote from: "Laurent"
A complete and minimal example would be more helpful ;)


I really don't know what you are asking for. That is all the code that has anything to do with setting the frame rate limit. Unless you are interested in...

Code: [Select]

std::auto_ptr< App > Game(
    App::CreateApp(
      "Kickle!",
      Configuration::GetScreenWidth(),
      Configuration::GetScreenHeight(),
      Configuration::GetFPS()
    )
  );


Where GetFPS() returns 60. If you could give me an idea of what you are trying to isolate I could be of more assistance.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #9 on: April 05, 2010, 12:53:06 am »
Quote from: "als"
I really don't know what you are asking for.
Laurent needs a complete example, i.e. one that is ready to be compiled. No missing declarations or anything. So, it can't be only a part of your code (like the constructor definition).

The other point is minimal, which means you shall not copy your whole project in here, rather a few lines that reproduce the mentioned problem. When the irrelevant code is left out, we can concentrate on the error itsself.

I hope you understand that this simplifies work a lot for all the people helping you. We like to help, but we don't want to guess or to browse tons of code. You have to contribute your part. And the "complete and minimal example that reproduces the problem" is your part. ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

als

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #10 on: April 10, 2010, 03:37:18 am »
Solved by setting vertical sync to true.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #11 on: April 10, 2010, 07:37:27 pm »
Quote from: "als"
Solved by setting vertical sync to true.

That doesn't mean it's solved. You just found another way to limit frames.

als

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #12 on: April 10, 2010, 08:41:17 pm »
Quote from: "panithadrum"
Quote from: "als"
Solved by setting vertical sync to true.

That doesn't mean it's solved. You just found another way to limit frames.


I can tell that SetFrameLimit is now working because I tried limiting to several values, and they all worked correctly. The frames are now being limited. I'm sorry if you don't consider it an adequate solution, but for my purposes it's fine, and it can be done with one line of code.

The reason I posted what worked for me was so that if others have the same problem and find this thread they can try it. If it works for them, great. Try enabling vertical sync.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
SFML SetFramerateLimit Not Limiting Frame Rate
« Reply #13 on: April 11, 2010, 07:39:42 am »
Quote from: "als"
Quote from: "panithadrum"
Quote from: "als"
Solved by setting vertical sync to true.

That doesn't mean it's solved. You just found another way to limit frames.


I can tell that SetFrameLimit is now working because I tried limiting to several values, and they all worked correctly. The frames are now being limited. I'm sorry if you don't consider it an adequate solution, but for my purposes it's fine, and it can be done with one line of code.

The reason I posted what worked for me was so that if others have the same problem and find this thread they can try it. If it works for them, great. Try enabling vertical sync.
There's a huge problem with vertical sync. On different computers, vertical sync can give VERY different frame rates. It can give 60, 30(rare), 75, or even 120! Also, when you use vertical sync, if the program lags, it will run at half or even a quarter of the preferred fps! So if you're running your monitor at 60FPS, lag would drop it to 30, then to 15. There would be no in between.
I use the latest build of SFML2