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

Author Topic: Unstable fps  (Read 1801 times)

0 Members and 1 Guest are viewing this topic.

mrlambo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Unstable fps
« 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 :'(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10820
    • View Profile
    • development blog
    • Email
Re: Unstable fps
« Reply #1 on: April 16, 2016, 12:07:46 pm »
Does your code also contain setFramerateLimit(), you should not mix these two "modes".
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Unstable fps
« Reply #2 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.

mrlambo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Unstable fps
« Reply #3 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! :-[

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Unstable fps
« Reply #4 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*