Hi
the main loop in the sfml sample from the book is like so :
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;
while (mWindow.isOpen())
{
sf::Time dt = clock.restart();
timeSinceLastUpdate += dt;
while (timeSinceLastUpdate > TimePerFrame)
{
timeSinceLastUpdate -= TimePerFrame;
processInput();
update(TimePerFrame);
// Check inside this loop, because stack might be empty before update() call
if (mStateStack.isEmpty())
mWindow.close();
}
updateStatistics(dt);
render();
}
what's the point of the inner while() loop ? If I understand correctly this will potentially call the input / process functions several times if the previous frame was rendered too slowly... but shouldn't this be handled by the input function who will poll all the queued events anyway ? Also the input / process block can be skipped if timeSinceLastUpdate <= TimePerFrame, but I don't understand what is the point of this.