aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-07-21 22:02:54 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-07-21 22:02:54 +0000
commit98228cce0dfe6591dc1b3a1c44852be0ca2adb4f (patch)
treebc6877fd3c06a4b8fc246d874737f195ec9713b5
parentae6f1c7f5d75be89cb177c114fb184f0ed34ef6e (diff)
downloadioquake3-aero-98228cce0dfe6591dc1b3a1c44852be0ca2adb4f.tar.gz
ioquake3-aero-98228cce0dfe6591dc1b3a1c44852be0ca2adb4f.zip
* 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 git-svn-id: svn://svn.icculus.org/quake3/trunk@1431 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r--README10
-rw-r--r--code/qcommon/common.c19
-rw-r--r--code/qcommon/qcommon.h2
-rw-r--r--code/sdl/sdl_input.c11
-rw-r--r--code/sys/sys_main.c44
-rw-r--r--code/sys/sys_unix.c3
-rw-r--r--code/sys/sys_win32.c3
7 files changed, 39 insertions, 53 deletions
diff --git a/README b/README
index e74203f..d76ce59 100644
--- a/README
+++ b/README
@@ -116,7 +116,7 @@ New cvars
s_alRolloff - the value of AL_ROLLOFF_FACTOR for each
source
s_alGraceDistance - after having passed MaxDistance, length
- until sounds are completely inaudible.
+ until sounds are completely inaudible
s_alDriver - which OpenAL library to use
s_alDevice - which OpenAL device to use
s_alAvailableDevices - list of available OpenAL devices
@@ -129,7 +129,9 @@ New cvars
com_ansiColor - enable use of ANSI escape codes in the tty
com_altivec - enable use of altivec on PowerPC systems
- com_standalone - Run in standalone mode.
+ com_standalone - Run in standalone mode
+ com_maxfpsUnfocused - Maximum frames per second when unfocused
+ com_maxfpsMinimized - Maximum frames per second when minimized
s_backend - read only, indicates the current sound
backend
s_muteWhenMinimized - mute sound when minimized
@@ -165,13 +167,13 @@ New cvars
just add 3 to the value for the wanted
color combination. For red-blue and
red-green you probably want to enable
- r_greyscale.
+ r_greyscale
r_stereoSeparation - Control eye separation. Resulting
separation is r_zProj divided by this
value in quake3 standard units.
See also
http://wiki.ioquake3.org/Stereo_Rendering
- for more information.
+ for more information
New commands
video [filename] - start video capture (use with demo command)
diff --git a/code/qcommon/common.c b/code/qcommon/common.c
index 5888592..52bc5f6 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -81,7 +81,9 @@ cvar_t *sv_packetdelay;
cvar_t *com_cameraMode;
cvar_t *com_ansiColor;
cvar_t *com_unfocused;
+cvar_t *com_maxfpsUnfocused;
cvar_t *com_minimized;
+cvar_t *com_maxfpsMinimized;
cvar_t *com_standalone;
// com_speeds times
@@ -2604,7 +2606,9 @@ void Com_Init( char *commandLine ) {
com_ansiColor = Cvar_Get( "com_ansiColor", "0", CVAR_ARCHIVE );
com_unfocused = Cvar_Get( "com_unfocused", "0", CVAR_ROM );
+ com_maxfpsUnfocused = Cvar_Get( "com_maxfpsUnfocused", "0", CVAR_ARCHIVE );
com_minimized = Cvar_Get( "com_minimized", "0", CVAR_ROM );
+ com_maxfpsMinimized = Cvar_Get( "com_maxfpsMinimized", "0", CVAR_ARCHIVE );
com_standalone = Cvar_Get( "com_standalone", "0", CVAR_INIT );
com_introPlayed = Cvar_Get( "com_introplayed", "0", CVAR_ARCHIVE);
@@ -2844,12 +2848,23 @@ void Com_Frame( void ) {
}
// we may want to spin here if things are going too fast
- if ( !com_dedicated->integer && com_maxfps->integer > 0 && !com_timedemo->integer ) {
- minMsec = 1000 / com_maxfps->integer;
+ if ( !com_dedicated->integer && !com_timedemo->integer ) {
+ if( com_minimized->integer && com_maxfpsMinimized->integer ) {
+ minMsec = 1000 / com_maxfpsMinimized->integer;
+ } else if( com_unfocused->integer && com_maxfpsUnfocused->integer ) {
+ minMsec = 1000 / com_maxfpsUnfocused->integer;
+ } else if( com_maxfps->integer ) {
+ minMsec = 1000 / com_maxfps->integer;
+ } else {
+ minMsec = 1;
+ }
} else {
minMsec = 1;
}
+
+ msec = minMsec;
do {
+ Sys_Sleep( minMsec - msec );
com_frameTime = Com_EventLoop();
if ( lastTime > com_frameTime ) {
lastTime = com_frameTime; // possible on first frame
diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h
index c5efef8..34a9780 100644
--- a/code/qcommon/qcommon.h
+++ b/code/qcommon/qcommon.h
@@ -803,7 +803,9 @@ extern cvar_t *com_journal;
extern cvar_t *com_cameraMode;
extern cvar_t *com_ansiColor;
extern cvar_t *com_unfocused;
+extern cvar_t *com_maxfpsUnfocused;
extern cvar_t *com_minimized;
+extern cvar_t *com_maxfpsMinimized;
extern cvar_t *com_altivec;
// both client and server must agree to pause
diff --git a/code/sdl/sdl_input.c b/code/sdl/sdl_input.c
index d6005fb..6287f8e 100644
--- a/code/sdl/sdl_input.c
+++ b/code/sdl/sdl_input.c
@@ -348,7 +348,7 @@ static void IN_DeactivateMouse( void )
if( mouseActive )
{
SDL_WM_GrabInput( SDL_GRAB_OFF );
- SDL_WarpMouse( glConfig.vidWidth >> 1, glConfig.vidHeight >> 1 );
+ SDL_WarpMouse( glConfig.vidWidth / 2, glConfig.vidHeight / 2 );
SDL_ShowCursor( 1 );
mouseActive = qfalse;
@@ -716,15 +716,6 @@ static void IN_ProcessEvents( void )
}
break;
- case SDL_ACTIVEEVENT:
- if( e.active.state == SDL_APPINPUTFOCUS ) {
- if( e.active.gain )
- IN_ActivateMouse();
- else
- IN_DeactivateMouse();
- }
- break;
-
case SDL_QUIT:
Sys_Quit();
break;
diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c
index a1a57b4..dc846dd 100644
--- a/code/sys/sys_main.c
+++ b/code/sys/sys_main.c
@@ -441,42 +441,6 @@ void *Sys_LoadDll( const char *name, char *fqpath ,
/*
=================
-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( );
}
diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c
index 9d9d5aa..40479b9 100644
--- a/code/sys/sys_unix.c
+++ b/code/sys/sys_unix.c
@@ -463,6 +463,9 @@ void Sys_Sleep( int msec )
{
fd_set fdset;
+ if( msec == 0 )
+ return;
+
FD_ZERO(&fdset);
FD_SET(fileno(stdin), &fdset);
if( msec < 0 )
diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c
index 18724b3..fb924e6 100644
--- a/code/sys/sys_win32.c
+++ b/code/sys/sys_win32.c
@@ -519,6 +519,9 @@ Block execution for msec or until input is recieved.
*/
void Sys_Sleep( int msec )
{
+ if( msec == 0 )
+ return;
+
if( msec < 0 )
WaitForSingleObject( GetStdHandle( STD_INPUT_HANDLE ), INFINITE );
else