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

Author Topic: Just a quick query is all.  (Read 1578 times)

0 Members and 1 Guest are viewing this topic.

smilesprower

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Just a quick query is all.
« 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();
        }
}
 

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Just a quick query is all.
« Reply #1 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).

 

anything