diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp index e41baf72a..a71742415 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp @@ -242,6 +242,27 @@ bool versionCorrect(int major, int minor) #endif } + +// Used in OptionsScreenVideo for live updating vertical sync config +extern "C" void update_swap_interval(int swap_interval) +{ +#ifndef IOS_STK + // iOS always use vertical sync + if (swap_interval > 1) + swap_interval = 1; + + // Try adaptive vsync first if support + if (swap_interval > 0) + { + int ret = SDL_GL_SetSwapInterval(-1); + if (ret == 0) + return; + } + SDL_GL_SetSwapInterval(swap_interval); +#endif +} + + bool CIrrDeviceSDL::createWindow() { // Ignore alpha size here, this follow irr_driver.cpp:450 @@ -287,11 +308,7 @@ bool CIrrDeviceSDL::createWindow() return false; } - int swap_interval = CreationParams.SwapInterval; - if (swap_interval > 1) - swap_interval = 1; - SDL_GL_SetSwapInterval(swap_interval); - + update_swap_interval(CreationParams.SwapInterval); return true; } diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp index 99665c3b2..58b0b434c 100644 --- a/src/states_screens/options/options_screen_video.cpp +++ b/src/states_screens/options/options_screen_video.cpp @@ -615,6 +615,7 @@ void OptionsScreenVideo::updateBlurTooltip() } // updateBlurTooltip // -------------------------------------------------------------------------------------------- +extern "C" void update_swap_interval(int swap_interval); void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, const int playerID) @@ -726,6 +727,9 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, GUIEngine::SpinnerWidget* vsync = getWidget("vsync"); assert( vsync != NULL ); UserConfigParams::m_swap_interval = vsync->getValue(); +#if !defined(SERVER_ONLY) && defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + update_swap_interval(UserConfigParams::m_swap_interval); +#endif } else if (name == "rememberWinpos") {