Fix framerate limiter

This commit is contained in:
Li 2023-03-15 20:53:00 +13:00
parent d3e8c9a343
commit 98b5577a9a
3 changed files with 14 additions and 14 deletions

View File

@ -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();
}
}

View File

@ -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;

View File

@ -13,6 +13,7 @@ namespace Li::Gui {
SDL_Window* window;
Renderer* renderer;
bool isExiting;
public:
bool IsExiting();
void NewFrame();