* Use Sys_Sleep to limit FPS, which will save CPU
* Add com_maxfpsUnfocused and com_maxfpsMinimized; self explanatory * Fix reopening of bug 3703, I hope
This commit is contained in:
parent
4ceb51e6ba
commit
0124371c01
7 changed files with 39 additions and 53 deletions
|
@ -439,42 +439,6 @@ void *Sys_LoadDll( const char *name, char *fqpath ,
|
|||
return libHandle;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Sys_Idle
|
||||
=================
|
||||
*/
|
||||
static void Sys_Idle( void )
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
int appState = SDL_GetAppState( );
|
||||
int sleep = 0;
|
||||
|
||||
// If we have no input focus at all, sleep a bit
|
||||
if( !( appState & ( SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS ) ) )
|
||||
{
|
||||
Cvar_SetValue( "com_unfocused", 1 );
|
||||
sleep += 16;
|
||||
}
|
||||
else
|
||||
Cvar_SetValue( "com_unfocused", 0 );
|
||||
|
||||
// If we're minimised, sleep a bit more
|
||||
if( !( appState & SDL_APPACTIVE ) )
|
||||
{
|
||||
Cvar_SetValue( "com_minimized", 1 );
|
||||
sleep += 32;
|
||||
}
|
||||
else
|
||||
Cvar_SetValue( "com_minimized", 0 );
|
||||
|
||||
if( !com_dedicated->integer && sleep )
|
||||
SDL_Delay( sleep );
|
||||
#else
|
||||
// Dedicated server idles via NET_Sleep
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Sys_ParseArgs
|
||||
|
@ -602,7 +566,13 @@ int main( int argc, char **argv )
|
|||
|
||||
while( 1 )
|
||||
{
|
||||
Sys_Idle( );
|
||||
#ifndef DEDICATED
|
||||
int appState = SDL_GetAppState( );
|
||||
|
||||
Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) );
|
||||
Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) );
|
||||
#endif
|
||||
|
||||
IN_Frame( );
|
||||
Com_Frame( );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue