SFML community forums
Help => Window => Topic started by: als 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."
-
Could you show a complete and minimal example that reproduces the problem?
-
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.
http://www.youtube.com/watch?v=NVPd-lRPLZQ
-
Well, I was talking about source code ;)
-
Yes, but it would be more helpful if you posted a short piece of code that shows the mentioned problem.
-
Here is the app constructor that sets the frame rate limit.
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() );
}
-
A complete and minimal example would be more helpful ;)
-
http://www.youtube.com/watch?v=NVPd-lRPLZQ
HAHA, Kickle Cubicle, sweet old NES memories. :')
-
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...
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.
-
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. ;)
-
Solved by setting vertical sync to true.
-
Solved by setting vertical sync to true.
That doesn't mean it's solved. You just found another way to limit frames.
-
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.
-
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.