diff --git a/DumpDVD/Gui/DumpDVD.cpp b/DumpDVD/Gui/DumpDVD.cpp index f40f8c3..d5f4e99 100644 --- a/DumpDVD/Gui/DumpDVD.cpp +++ b/DumpDVD/Gui/DumpDVD.cpp @@ -102,7 +102,7 @@ namespace Li::Gui { while (this->keepPolling) { if ( (this->counter % (60 * 10)) == 0) { this->lock->lock(); - refreshDriveList(); + this->refreshDriveList(); this->lock->unlock(); } } diff --git a/DumpDVD/Gui/MainWindow.cpp b/DumpDVD/Gui/MainWindow.cpp index 55180ef..b3452f5 100644 --- a/DumpDVD/Gui/MainWindow.cpp +++ b/DumpDVD/Gui/MainWindow.cpp @@ -14,26 +14,25 @@ #include "DumpDVD.hpp" namespace Li::Gui { - - - MainWindow::MainWindow() { this->sdl = new SDL("DumpDVD", 800, 400); DumpDVD* dumpDvdMenu = new DumpDVD(); - + uint32_t lastRenderTime = SDL_GetTicks(); while (!this->sdl->IsExiting()) { - uint64_t start = SDL_GetPerformanceCounter(); - this->sdl->PollEvent(); - this->sdl->NewFrame(); + uint32_t curRenderTime = SDL_GetTicks(); + uint32_t delta = curRenderTime - lastRenderTime; + if (delta > 1000 / 60.0) + { + this->sdl->PollEvent(); + this->sdl->NewFrame(); - dumpDvdMenu->RenderUI(); + 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)); + this->sdl->Render(); + + lastRenderTime = curRenderTime; + } } delete dumpDvdMenu; diff --git a/DumpDVD/Gui/SDL.hpp b/DumpDVD/Gui/SDL.hpp index 2a3bc13..bec75d6 100644 --- a/DumpDVD/Gui/SDL.hpp +++ b/DumpDVD/Gui/SDL.hpp @@ -13,6 +13,7 @@ namespace Li::Gui { SDL_Window* window; Renderer* renderer; bool isExiting; + public: bool IsExiting(); void NewFrame();