mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-13 22:22:05 +00:00
Merge branch '752-background-fps-limit' into sdl-joykeys
This commit is contained in:
commit
2997fe9f02
5 changed files with 41 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2012-2014 Robert Beckebans
|
||||
Copyright (C) 2012-2025 Robert Beckebans
|
||||
Copyright (C) 2022 Stephen Pridham
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
@ -97,12 +97,13 @@ idCVar net_inviteOnly( "net_inviteOnly", "1", CVAR_BOOL | CVAR_ARCHIVE, "whether
|
|||
// DG: add cvar for pause
|
||||
idCVar com_pause( "com_pause", "0", CVAR_BOOL | CVAR_SYSTEM | CVAR_NOCHEAT, "set to 1 to pause game, to 0 to unpause again" );
|
||||
// DG end
|
||||
idCVar com_activeApp( "com_activeApp", "1", CVAR_BOOL | CVAR_SYSTEM | CVAR_NOCHEAT, "this is set to 0 if running in background" );
|
||||
|
||||
extern idCVar g_demoMode;
|
||||
|
||||
idCVar com_engineHz( "com_engineHz", "60", CVAR_FLOAT | CVAR_ARCHIVE, "Frames per second the engine runs at", 10.0f, 1024.0f );
|
||||
float com_engineHz_latched = 60.0f; // Latched version of cvar, updated between map loads
|
||||
int64 com_engineHz_numerator = 100LL * 1000LL;
|
||||
const int64 com_engineHz_numerator = 100LL * 1000LL;
|
||||
int64 com_engineHz_denominator = 100LL * 60LL;
|
||||
|
||||
// RB begin
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2014-2016 Robert Beckebans
|
||||
Copyright (C) 2014-2025 Robert Beckebans
|
||||
Copyright (C) 2014-2016 Kot in Action Creative Artel
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
@ -41,7 +41,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
extern idCVar com_engineHz;
|
||||
extern float com_engineHz_latched;
|
||||
extern int64 com_engineHz_numerator;
|
||||
extern const int64 com_engineHz_numerator;
|
||||
extern int64 com_engineHz_denominator;
|
||||
|
||||
// Returns the msec the frame starts on
|
||||
|
|
|
@ -520,6 +520,7 @@ void idCommonLocal::ProcessGameReturn( const gameReturn_t& ret )
|
|||
extern idCVar com_forceGenericSIMD;
|
||||
|
||||
extern idCVar com_pause;
|
||||
extern idCVar com_activeApp;
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -641,6 +642,21 @@ void idCommonLocal::Frame()
|
|||
}
|
||||
frameTiming.finishSyncTime = Sys_Microseconds();
|
||||
|
||||
// RB: slow down engine in background so it does not eat up so many resources along other 3D tools
|
||||
if( !com_activeApp.GetBool() /* and not VR */ )
|
||||
{
|
||||
const float backgroundEngineHz = 15.0f;
|
||||
com_engineHz_denominator = 100LL * backgroundEngineHz;
|
||||
com_engineHz_latched = backgroundEngineHz;
|
||||
}
|
||||
else
|
||||
{
|
||||
// allow com_engineHz to be changed between map loads
|
||||
com_engineHz_denominator = 100LL * com_engineHz.GetFloat();
|
||||
com_engineHz_latched = com_engineHz.GetFloat();
|
||||
}
|
||||
// RB end
|
||||
|
||||
//--------------------------------------------
|
||||
// Determine how many game tics we are going to run,
|
||||
// now that the previous frame is completely finished.
|
||||
|
@ -688,12 +704,16 @@ void idCommonLocal::Frame()
|
|||
gameTimeResidual += clampedDeltaMilliseconds * timescale.GetFloat();
|
||||
|
||||
// don't run any frames when paused
|
||||
/*
|
||||
RB moved down
|
||||
|
||||
if( pauseGame )
|
||||
{
|
||||
gameFrame++;
|
||||
gameTimeResidual = 0;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
// debug cvar to force multiple game tics
|
||||
if( com_fixedTic.GetInteger() > 0 )
|
||||
|
@ -753,6 +773,14 @@ void idCommonLocal::Frame()
|
|||
}
|
||||
}
|
||||
|
||||
// don't run any frames when paused
|
||||
// RB: reset numGameFrames here so we use the sleep above
|
||||
// and don't run as many frames as possible on the GPU
|
||||
if( pauseGame )
|
||||
{
|
||||
numGameFrames = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// It would be better to push as much of this as possible
|
||||
// either before or after the renderSystem->SwapCommandBuffers(),
|
||||
|
|
|
@ -452,6 +452,7 @@ sysEvent_t Sys_GetEvent()
|
|||
// DG: un-pause the game when focus is gained, that also re-grabs the input
|
||||
// disabling the cursor is now done once in GLimp_Init() because it should always be disabled
|
||||
cvarSystem->SetCVarBool( "com_pause", false );
|
||||
cvarSystem->SetCVarBool( "com_activeApp", true );
|
||||
// DG end
|
||||
break;
|
||||
}
|
||||
|
@ -459,6 +460,7 @@ sysEvent_t Sys_GetEvent()
|
|||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
// DG: pause the game when focus is lost, that also un-grabs the input
|
||||
cvarSystem->SetCVarBool( "com_pause", true );
|
||||
cvarSystem->SetCVarBool( "com_activeApp", false );
|
||||
// DG end
|
||||
break;
|
||||
|
||||
|
@ -701,6 +703,8 @@ sysEvent_t Sys_GetEvent()
|
|||
case SDL_JOYDEVICEADDED:
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
case SDL_JOYBATTERYUPDATED:
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
// Avoid 'unknown event' spam
|
||||
continue;
|
||||
|
||||
|
@ -805,7 +809,10 @@ sysEvent_t Sys_GetEvent()
|
|||
}
|
||||
continue; // just handle next event
|
||||
|
||||
// Avoid 'unknown event' spam
|
||||
case SDL_TEXTEDITING:
|
||||
case SDL_KEYMAPCHANGED:
|
||||
case SDL_CLIPBOARDUPDATE:
|
||||
continue; // just handle next event
|
||||
|
||||
default:
|
||||
|
|
|
@ -296,6 +296,7 @@ LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|||
// DG: set com_pause so game pauses when focus is lost
|
||||
// and continues when focus is regained
|
||||
cvarSystem->SetCVarBool( "com_pause", !win32.activeApp );
|
||||
cvarSystem->SetCVarBool( "com_activeApp", win32.activeApp );
|
||||
// DG end
|
||||
|
||||
// we do not actually grab or release the mouse here,
|
||||
|
|
Loading…
Reference in a new issue