-
-
Save mortennobel/9931de796161cf2da56e167ad1ad22da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while (running){ | |
frame(deltaTime); | |
auto tick = Clock::now(); | |
deltaTime = std::chrono::duration_cast<FpSeconds>(tick - lastTick).count(); | |
// todo fix busy wait | |
// https://forum.lazarus.freepascal.org/index.php?topic=35689.0 | |
while (deltaTime < timePerFrame){ | |
SDL_Delay((Uint32) ((timePerFrame - deltaTime) / 1000)); | |
tick = Clock::now(); | |
deltaTime = std::chrono::duration_cast<FpSeconds>(tick - lastTick).count(); | |
} | |
lastTick = tick; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment