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