Add support for adaptive vsync
This commit is contained in:
parent
a2675497e0
commit
5ca51fd2a9
@ -242,6 +242,27 @@ bool versionCorrect(int major, int minor)
|
|||||||
#endif
|
#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()
|
bool CIrrDeviceSDL::createWindow()
|
||||||
{
|
{
|
||||||
// Ignore alpha size here, this follow irr_driver.cpp:450
|
// Ignore alpha size here, this follow irr_driver.cpp:450
|
||||||
@ -287,11 +308,7 @@ bool CIrrDeviceSDL::createWindow()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int swap_interval = CreationParams.SwapInterval;
|
update_swap_interval(CreationParams.SwapInterval);
|
||||||
if (swap_interval > 1)
|
|
||||||
swap_interval = 1;
|
|
||||||
SDL_GL_SetSwapInterval(swap_interval);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,6 +615,7 @@ void OptionsScreenVideo::updateBlurTooltip()
|
|||||||
} // updateBlurTooltip
|
} // updateBlurTooltip
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
extern "C" void update_swap_interval(int swap_interval);
|
||||||
|
|
||||||
void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
||||||
const int playerID)
|
const int playerID)
|
||||||
@ -726,6 +727,9 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
GUIEngine::SpinnerWidget* vsync = getWidget<GUIEngine::SpinnerWidget>("vsync");
|
GUIEngine::SpinnerWidget* vsync = getWidget<GUIEngine::SpinnerWidget>("vsync");
|
||||||
assert( vsync != NULL );
|
assert( vsync != NULL );
|
||||||
UserConfigParams::m_swap_interval = vsync->getValue();
|
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")
|
else if (name == "rememberWinpos")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user