mirror of
https://github.com/dhewm/dhewm3.git
synced 2024-11-25 22:01:09 +00:00
Allow changing r_swapInterval (VSync) on-the-fly
Not supported with SDL1.2 - but that's only still supported by dhewm3 because I'm too lazy to rip it out :-p
This commit is contained in:
parent
139020f52b
commit
e3d67f0ac9
4 changed files with 22 additions and 2 deletions
|
@ -260,6 +260,10 @@ static void R_CheckCvars( void ) {
|
|||
R_SetColorMappings();
|
||||
}
|
||||
}
|
||||
|
||||
if ( r_swapInterval.IsModified() ) {
|
||||
GLimp_SetSwapInterval( r_swapInterval.GetInteger() );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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 );
|
||||
/*
|
||||
====================================================================
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue