diff --git a/neo/renderer/RenderSystem.cpp b/neo/renderer/RenderSystem.cpp index 722cf1ab..b1c374e4 100644 --- a/neo/renderer/RenderSystem.cpp +++ b/neo/renderer/RenderSystem.cpp @@ -260,6 +260,10 @@ static void R_CheckCvars( void ) { R_SetColorMappings(); } } + + if ( r_swapInterval.IsModified() ) { + GLimp_SetSwapInterval( r_swapInterval.GetInteger() ); + } } /* diff --git a/neo/renderer/tr_local.h b/neo/renderer/tr_local.h index 2ace6284..b798e260 100644 --- a/neo/renderer/tr_local.h +++ b/neo/renderer/tr_local.h @@ -1113,6 +1113,8 @@ const int GRAB_HIDECURSOR = (1 << 1); const int GRAB_RELATIVEMOUSE = (1 << 2); void GLimp_GrabInput(int flags); + +bool GLimp_SetSwapInterval( int swapInterval ); /* ==================================================================== diff --git a/neo/sys/glimp.cpp b/neo/sys/glimp.cpp index bff936da..fc1c55d6 100644 --- a/neo/sys/glimp.cpp +++ b/neo/sys/glimp.cpp @@ -404,8 +404,7 @@ try_again: context = SDL_GL_CreateContext(window); - if (SDL_GL_SetSwapInterval(r_swapInterval.GetInteger()) < 0) - common->Warning("SDL_GL_SWAP_CONTROL not supported"); + GLimp_SetSwapInterval( r_swapInterval.GetInteger() ); SDL_GetWindowSize(window, &glConfig.vidWidth, &glConfig.vidHeight); @@ -737,3 +736,17 @@ void GLimp_GrabInput(int flags) { SDL_WM_GrabInput( (flags & GRAB_RELATIVEMOUSE) ? SDL_GRAB_ON : SDL_GRAB_OFF ); #endif } + +bool GLimp_SetSwapInterval( int swapInterval ) +{ +#if SDL_VERSION_ATLEAST(2, 0, 0) + if ( SDL_GL_SetSwapInterval( swapInterval ) < 0 ) { + common->Warning( "SDL_GL_SetSwapInterval( %d ) not supported", swapInterval ); + return false; + } + return true; +#else + common->Warning( "SDL1.2 does not support changing the swapinterval (vsync) on-the-fly!" ); + return false; +#endif +} diff --git a/neo/sys/stub/stub_gl.cpp b/neo/sys/stub/stub_gl.cpp index af571081..9a861440 100644 --- a/neo/sys/stub/stub_gl.cpp +++ b/neo/sys/stub/stub_gl.cpp @@ -397,6 +397,7 @@ void GLimp_SwapBuffers() {}; void GLimp_ActivateContext() {}; void GLimp_DeactivateContext() {}; void GLimp_GrabInput(int flags) {}; +bool GLimp_SetSwapInterval( int swapInterval ) { return false; } #ifdef _MSC_VER #pragma warning(pop)