--- gfx_sdl2.c 2024-05-28 10:43:53 +++ gfx_sdl2.c.patched 2024-05-28 10:43:40 @@ -54,9 +54,11 @@ static const int frame_time = 1000 / (2 * FRAMERATE); // whether to use timer for frame control static bool use_timer = true; // time between consequtive game frames -static const int frame_time = 1000 / (2 * FRAMERATE); +static const int frame_time_60FPS = 1000 / (2 * FRAMERATE); +static const int frame_time_30FPS = 1000 / FRAMERATE; + const SDL_Scancode windows_scancode_table[] = { /* 0 1 2 3 4 5 6 7 */ /* 8 9 A B C D E F */ @@ -141,6 +143,9 @@ static inline void gfx_sdl_set_vsync(const bool enable } static inline void gfx_sdl_set_vsync(const bool enabled) { + use_timer = true; + SDL_GL_SetSwapInterval(0); + return; #ifdef TARGET_SWITCH use_timer = false; SDL_GL_SetSwapInterval(1); @@ -357,9 +362,15 @@ static inline void sync_framerate_with_timer(void) { // 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); - last_time += frame_time; + if(config60FPS){ + if (elapsed < frame_time_60FPS) + SDL_Delay(frame_time_60FPS - elapsed); + last_time += frame_time_60FPS; + }else{ + if (elapsed < frame_time_30FPS) + SDL_Delay(frame_time_30FPS - elapsed); + last_time += frame_time_30FPS; + } } static void gfx_sdl_swap_buffers_begin(void) {