GUI: fix division by zero when disabling frame rat

e limit
This commit is contained in:
tildearrow 2024-04-07 03:00:31 -05:00
parent a793f286c5
commit 03952b7564

View file

@ -6468,6 +6468,7 @@ bool FurnaceGUI::loop() {
drawTimeEnd=SDL_GetPerformanceCounter();
swapTimeBegin=SDL_GetPerformanceCounter();
if (!settings.vsync || !rend->canVSync()) {
if (settings.frameRateLimit>0) {
unsigned int presentDelay=SDL_GetPerformanceFrequency()/settings.frameRateLimit;
if ((nextPresentTime-swapTimeBegin)<presentDelay) {
#ifdef _WIN32
@ -6477,12 +6478,12 @@ bool FurnaceGUI::loop() {
unsigned int mDivider=SDL_GetPerformanceFrequency()/1000000;
usleep((unsigned int)(nextPresentTime-swapTimeBegin)/mDivider);
#endif
nextPresentTime+=presentDelay;
} else {
nextPresentTime=swapTimeBegin+presentDelay;
}
}
}
rend->present();
if (settings.renderClearPos) {
rend->clear(uiColors[GUI_COLOR_BACKGROUND]);