From 5aaa4e399ab3df2cd52932d29658b487a167991c Mon Sep 17 00:00:00 2001 From: fgsfds Date: Fri, 10 Jul 2020 15:44:58 +0300 Subject: [PATCH] don't assume first frame happens at 0 ticks --- src/pc/gfx/gfx_sdl2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 25c9f069..4d907893 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -328,6 +328,8 @@ static bool gfx_sdl_start_frame(void) { static inline void sync_framerate_with_timer(void) { static Uint32 last_time = 0; + // get base timestamp on the first frame (might be different from 0) + if (last_time == 0) last_time = SDL_GetTicks(); const int elapsed = SDL_GetTicks() - last_time; if (elapsed < frame_time) SDL_Delay(frame_time - elapsed);