SFML community forums

Help => Graphics => Topic started by: FRex on August 09, 2012, 03:01:47 am

Title: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
Post by: FRex 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?
Title: Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
Post by: Laurent on August 09, 2012, 07:57:23 am
You should read the tutorial (http://www.sfml-dev.org/tutorials/2.0/window-window.php) ("Controlling the framerate" section).
Title: Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
Post by: FRex 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);
        }
};
Title: Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
Post by: Laurent 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
Title: Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
Post by: FRex 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.