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

Author Topic: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)  (Read 2464 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1843
    • View Profile
    • My GitHub Page
    • Email
setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
« on: August 09, 2012, 03:01:47 am »
How do these two work together in a RenderWindow, mainly:
1. If both were called, is the limit used the the smaller/bigger one of them two, or one that was put on the screen with last call or something else?

2. Is there a way to get max fps that these two permit RenderWindow to have?

3. If setVerticalSyncEnable(true) is called first, then setFramerateLimit(x) with x being smaller than max fps permitted by vertical sync and then setFramerateLimit(0) is called, is limit now again what vertical sync permits or there is no limit at all?
ZipSavings, script to count rar/7z/zip savings: https://goo.gl/vvBj5M
LuaConsole: https://goo.gl/X4kRUk
FoxRaycaster: https://goo.gl/27nVS8
Small Games - Heart, Routing and Snek: https://goo.gl/15ZGWE https://goo.gl/k5gwWD https://goo.gl/4nKPnT
Botes - a notes app in Pascal: https://goo.gl/bzTqsi

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32466
    • View Profile
    • SFML's website
    • Email
Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
« Reply #1 on: August 09, 2012, 07:57:23 am »
You should read the tutorial ("Controlling the framerate" section).
Laurent Gomila - SFML developer

FRex

  • Hero Member
  • *****
  • Posts: 1843
    • View Profile
    • My GitHub Page
    • Email
Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
« Reply #2 on: August 09, 2012, 09:12:57 pm »
Would class like this be safe?
class SafeRW : public sf::RenderWindow
{
public:
        SafeRW(void);
        SafeRW(sf::WindowHandle handle,const sf::ContextSettings& settings = sf::ContextSettings()):
        sf::RenderWindow(handle,settings){}
        SafeRW(sf::VideoMode mode,const std::string& title,sf::Uint32 style = sf::Style::Default, const sf::ContextSettings& settings = sf::ContextSettings()):
        sf::RenderWindow(mode,title,style,settings){}
        virtual ~SafeRW(void){};
        void setFramerateLimit(unsigned int limit)
        {

                sf::RenderWindow::setVerticalSyncEnabled(false);
                sf::RenderWindow::setFramerateLimit(limit);
        }
        void setVerticalSyncEnabled(bool enabled)
        {
                sf::RenderWindow::setFramerateLimit(0);
                sf::RenderWindow::setVerticalSyncEnabled(enabled);
        }
};
ZipSavings, script to count rar/7z/zip savings: https://goo.gl/vvBj5M
LuaConsole: https://goo.gl/X4kRUk
FoxRaycaster: https://goo.gl/27nVS8
Small Games - Heart, Routing and Snek: https://goo.gl/15ZGWE https://goo.gl/k5gwWD https://goo.gl/4nKPnT
Botes - a notes app in Pascal: https://goo.gl/bzTqsi

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32466
    • View Profile
    • SFML's website
    • Email
Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
« Reply #3 on: August 09, 2012, 09:21:17 pm »
Hmm yes. But do you really need such a class? Is it really too hard to not activate both in your program? :P
Laurent Gomila - SFML developer

FRex

  • Hero Member
  • *****
  • Posts: 1843
    • View Profile
    • My GitHub Page
    • Email
Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
« Reply #4 on: August 10, 2012, 01:20:22 am »
Well not really anymore. :P But there was part of code that I wanted to limit to lower framerate because of amount of sf::VertexArrays stored in vector of vectors with 1 quad each but I changed that part now.
ZipSavings, script to count rar/7z/zip savings: https://goo.gl/vvBj5M
LuaConsole: https://goo.gl/X4kRUk
FoxRaycaster: https://goo.gl/27nVS8
Small Games - Heart, Routing and Snek: https://goo.gl/15ZGWE https://goo.gl/k5gwWD https://goo.gl/4nKPnT
Botes - a notes app in Pascal: https://goo.gl/bzTqsi

 

anything