Fix framerate limiter
This commit is contained in:
parent
d3e8c9a343
commit
98b5577a9a
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Li::Gui {
|
|||
SDL_Window* window;
|
||||
Renderer* renderer;
|
||||
bool isExiting;
|
||||
|
||||
public:
|
||||
bool IsExiting();
|
||||
void NewFrame();
|
||||
|
|
Loading…
Reference in New Issue