SFML community forums

Help => General => Topic started by: mrlambo on April 16, 2016, 02:38:20 am

Title: Unstable fps
Post by: mrlambo on April 16, 2016, 02:38:20 am
Hello,

I got unstable fps using vsync, it keeps varying around 55fps and stuttering as well. I'm using the example code from sfml learning introduction, just added one line to enable vsync. Tested with mingw and vc12 precompiled libs, 32 and 64 bit. Just to note, it doesn't happen with sdl2 and games.

Tried not using vsync but, i always got a strange stutter, that also happens when using vsync. Fixed and simple timestep, not using sleep, just sf::Time. No moving entities, just moving my cam like camera.move(4, 0);. Also tried with setFramerateLimit(), but it stutters too.

What do? I need smooth motion :'(
Title: Re: Unstable fps
Post by: eXpl0it3r on April 16, 2016, 12:07:46 pm
Does your code also contain setFramerateLimit(), you should not mix these two "modes".
Title: Re: Unstable fps
Post by: Jesper Juhl on April 16, 2016, 12:56:59 pm
If your code is not able to achieve 60fps on your hardware or contains issues that cause some frames to occasionally take a significantly longer time than other frames. Then neither vsync nor SFML will be able to keep your FPS at 60 nor keep it stable/smooth.
Title: Re: Unstable fps
Post by: mrlambo on April 17, 2016, 02:52:06 am
Does your code also contain setFramerateLimit(), you should not mix these two "modes".

It doesn't, only vsync or a simple loop timed with sf::Time. Also i don't use sf:sleep() due to its precision, nonetheless, on sdl2 i'm able to use SDL_Delay() without any precision issues. How could i achieve this on sfml?

If your code is not able to achieve 60fps on your hardware or contains issues that cause some frames to occasionally take a significantly longer time than other frames. Then neither vsync nor SFML will be able to keep your FPS at 60 nor keep it stable/smooth.

The code i'm using is very simple. You can find it at this page: http://www.sfml-dev.org/tutorials/2.3/start-cb.php Just put one line to enable vsync OR a timer with sf::Time to keep the fps at 60. Anyway, thanks for the heads-up!

Sorry for the bad english! :-[
Title: Re: Unstable fps
Post by: Hapax on April 17, 2016, 11:29:31 pm
For a precise delay, you can loop until a certain amount of time has passed.
Note that the program is still running during this loop and therefore is not giving up any CPU time.