Fix framerate limiter
This commit is contained in:
parent
d3e8c9a343
commit
98b5577a9a
|
@ -102,7 +102,7 @@ namespace Li::Gui {
|
||||||
while (this->keepPolling) {
|
while (this->keepPolling) {
|
||||||
if ( (this->counter % (60 * 10)) == 0) {
|
if ( (this->counter % (60 * 10)) == 0) {
|
||||||
this->lock->lock();
|
this->lock->lock();
|
||||||
refreshDriveList();
|
this->refreshDriveList();
|
||||||
this->lock->unlock();
|
this->lock->unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,26 +14,25 @@
|
||||||
#include "DumpDVD.hpp"
|
#include "DumpDVD.hpp"
|
||||||
|
|
||||||
namespace Li::Gui {
|
namespace Li::Gui {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow() {
|
MainWindow::MainWindow() {
|
||||||
this->sdl = new SDL("DumpDVD", 800, 400);
|
this->sdl = new SDL("DumpDVD", 800, 400);
|
||||||
|
|
||||||
DumpDVD* dumpDvdMenu = new DumpDVD();
|
DumpDVD* dumpDvdMenu = new DumpDVD();
|
||||||
|
uint32_t lastRenderTime = SDL_GetTicks();
|
||||||
while (!this->sdl->IsExiting()) {
|
while (!this->sdl->IsExiting()) {
|
||||||
uint64_t start = SDL_GetPerformanceCounter();
|
uint32_t curRenderTime = SDL_GetTicks();
|
||||||
this->sdl->PollEvent();
|
uint32_t delta = curRenderTime - lastRenderTime;
|
||||||
this->sdl->NewFrame();
|
if (delta > 1000 / 60.0)
|
||||||
|
{
|
||||||
|
this->sdl->PollEvent();
|
||||||
|
this->sdl->NewFrame();
|
||||||
|
|
||||||
dumpDvdMenu->RenderUI();
|
dumpDvdMenu->RenderUI();
|
||||||
|
|
||||||
this->sdl->Render();
|
this->sdl->Render();
|
||||||
uint64_t end = SDL_GetPerformanceCounter();
|
|
||||||
float elapsedMS = (end - start) / (float)SDL_GetPerformanceFrequency() * 1000.0f;
|
lastRenderTime = curRenderTime;
|
||||||
// Cap to 60 FPS
|
}
|
||||||
SDL_Delay(floor(16.666f - elapsedMS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete dumpDvdMenu;
|
delete dumpDvdMenu;
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Li::Gui {
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
Renderer* renderer;
|
Renderer* renderer;
|
||||||
bool isExiting;
|
bool isExiting;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool IsExiting();
|
bool IsExiting();
|
||||||
void NewFrame();
|
void NewFrame();
|
||||||
|
|
Loading…
Reference in New Issue