SFML community forums

Help => General => Topic started by: smilesprower on September 24, 2016, 01:28:25 pm

Title: Just a quick query is all.
Post by: smilesprower on September 24, 2016, 01:28:25 pm
I was just wondering about general things from the code below is anyone can help.

#1 Does calling process"Polling Events" matter that its only updated 60 times a second ?
#2 Is it a waste to render as fast as possible ?

Thanks

// This code is from https://github.com/SFML/SFML-Game-Development-Book
void Game::run()
{
        sf::Clock clock;
        sf::Time timeSinceLastUpdate = sf::Time::Zero;
        while (mWindow.isOpen())
        {
                sf::Time elapsedTime = clock.restart();
                timeSinceLastUpdate += elapsedTime;
                while (timeSinceLastUpdate > TimePerFrame)
                {
                        timeSinceLastUpdate -= TimePerFrame;

                        processEvents();
                        update(TimePerFrame);
                }

                updateStatistics(elapsedTime);
                render();
        }
}
 
Title: Re: Just a quick query is all.
Post by: Mario on September 24, 2016, 09:45:53 pm
#1 Does calling process"Polling Events" matter that its only updated 60 times a second ?
Not really. You won't see any visual change without an update anyway. So in the end the structure will essentially be the same once executed, no matter whether you poll events outside or inside the "delta time loop".

#2 Is it a waste to render as fast as possible ?
You'll always want to render as efficient as possible, but there's no gain in rendering more often than what a screen may display, especially on mobile platforms (but also on notebooks), because doing so will just waste more energy without any real gain (even if you're not running off batteries).