diff --git a/src/display.c b/src/display.c index 32ed63dbe..95ed91cf2 100644 --- a/src/display.c +++ b/src/display.c @@ -635,16 +635,18 @@ float display_get_delta_time(void) void display_set_fps_limit(float fps) { + assert(fps >= 0.0f); + disable_interrupts(); - min_refresh_period = 1.0f / (fps ? fps : refresh_rate); + min_refresh_period = 1.0f / (fps ? MIN(fps, refresh_rate) : refresh_rate); frame_skip = refresh_period / min_refresh_period; delta_time = min_refresh_period; // Calculate also the minimum period using a rounded refresh rate // This will be used only for display purposes, so that FPS are capped // to 60 Hz rather than 59.83 Hz, which would be the hw-accurate value. - min_refresh_period_rounded = 1.0f / (fps ? fps : roundf(refresh_rate)); + min_refresh_period_rounded = 1.0f / (fps ? MIN(fps, roundf(refresh_rate)) : roundf(refresh_rate)); enable_interrupts(); }