Limit FPS to 60fps

This commit is contained in:
Li 2023-03-15 20:21:59 +13:00
parent b6f21843d0
commit d3e8c9a343
1 changed files with 5 additions and 0 deletions

View File

@ -23,12 +23,17 @@ namespace Li::Gui {
DumpDVD* dumpDvdMenu = new DumpDVD();
while (!this->sdl->IsExiting()) {
uint64_t start = SDL_GetPerformanceCounter();
this->sdl->PollEvent();
this->sdl->NewFrame();
dumpDvdMenu->RenderUI();
this->sdl->Render();
uint64_t end = SDL_GetPerformanceCounter();
float elapsedMS = (end - start) / (float)SDL_GetPerformanceFrequency() * 1000.0f;
// Cap to 60 FPS
SDL_Delay(floor(16.666f - elapsedMS));
}
delete dumpDvdMenu;