diff --git a/core/wsi/sdl.cpp b/core/wsi/sdl.cpp index a07a86b16..9fa3abfea 100644 --- a/core/wsi/sdl.cpp +++ b/core/wsi/sdl.cpp @@ -85,7 +85,21 @@ bool SDLGLGraphicsContext::Init() // Swap immediately swapOnVSync = false; #endif - SDL_GL_SetSwapInterval((int)swapOnVSync); + swapInterval = 1; + int displayIndex = SDL_GetWindowDisplayIndex(window); + if (displayIndex < 0) + WARN_LOG(RENDERER, "Cannot get the window display index: %s", SDL_GetError()); + else + { + SDL_DisplayMode mode{}; + if (SDL_GetDesktopDisplayMode(displayIndex, &mode) == 0) { + INFO_LOG(RENDERER, "Monitor refresh rate: %d Hz", mode.refresh_rate); + if (mode.refresh_rate > 100) + swapInterval = 2; + } + } + + SDL_GL_SetSwapInterval(swapOnVSync ? swapInterval : 0); #ifdef GLES load_gles_symbols(); @@ -109,7 +123,7 @@ void SDLGLGraphicsContext::Swap() if (swapOnVSync == (settings.input.fastForwardMode || !config::VSync)) { swapOnVSync = (!settings.input.fastForwardMode && config::VSync); - SDL_GL_SetSwapInterval((int)swapOnVSync); + SDL_GL_SetSwapInterval(swapOnVSync ? swapInterval : 0); } #endif SDL_GL_SwapWindow(window); diff --git a/core/wsi/sdl.h b/core/wsi/sdl.h index d1f9c5b29..83ec28d0d 100644 --- a/core/wsi/sdl.h +++ b/core/wsi/sdl.h @@ -46,6 +46,7 @@ private: SDL_Window* window = nullptr; SDL_GLContext glcontext = nullptr; bool swapOnVSync = false; + int swapInterval = 1; }; extern SDLGLGraphicsContext theGLContext;