add framerate control

This commit is contained in:
MihailRis
2024-07-28 22:31:27 +03:00
parent a2f011fc96
commit c0ba5be458
4 changed files with 20 additions and 6 deletions
-1
View File
@@ -325,7 +325,6 @@ bool Window::isFullscreen() {
void Window::swapBuffers() {
double currentTime = time();
if (framerate > 0 && currentTime - prevSwap < (1.0 / framerate)) {
std::cout << static_cast<int>((1.0/framerate - (currentTime-prevSwap))*1000) << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(
static_cast<int>((1.0/framerate - (currentTime-prevSwap))*1000)));
}