[quake3-commits] r1831 - trunk/code/sys

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Jan 31 15:23:05 EST 2011


Author: thilo
Date: 2011-01-31 15:23:05 -0500 (Mon, 31 Jan 2011)
New Revision: 1831

Modified:
   trunk/code/sys/sys_local.h
   trunk/code/sys/sys_unix.c
   trunk/code/sys/sys_win32.c
Log:
Explicitly set timer resolution on windows


Modified: trunk/code/sys/sys_local.h
===================================================================
--- trunk/code/sys/sys_local.h	2011-01-30 13:34:54 UTC (rev 1830)
+++ trunk/code/sys/sys_local.h	2011-01-31 20:23:05 UTC (rev 1831)
@@ -51,6 +51,7 @@
 void Sys_GLimpSafeInit( void );
 void Sys_GLimpInit( void );
 void Sys_PlatformInit( void );
+void Sys_PlatformExit( void );
 void Sys_SigHandler( int signal );
 void Sys_ErrorDialog( const char *error );
 void Sys_AnsiColorPrint( const char *msg );

Modified: trunk/code/sys/sys_unix.c
===================================================================
--- trunk/code/sys/sys_unix.c	2011-01-30 13:34:54 UTC (rev 1830)
+++ trunk/code/sys/sys_unix.c	2011-01-31 20:23:05 UTC (rev 1831)
@@ -741,6 +741,17 @@
 
 /*
 ==============
+Sys_PlatformExit
+
+Unix specific deinitialisation
+==============
+*/
+void Sys_PlatformExit( void )
+{
+}
+
+/*
+==============
 Sys_SetEnv
 
 set/unset environment variables (empty value removes it)

Modified: trunk/code/sys/sys_win32.c
===================================================================
--- trunk/code/sys/sys_win32.c	2011-01-30 13:34:54 UTC (rev 1830)
+++ trunk/code/sys/sys_win32.c	2011-01-31 20:23:05 UTC (rev 1831)
@@ -41,6 +41,8 @@
 // Used to determine where to store user-specific files
 static char homePath[ MAX_OSPATH ] = { 0 };
 
+static UINT timerResolution = 0;
+
 #ifdef __WIN64__
 void Sys_SnapVector( float *v )
 {
@@ -696,6 +698,9 @@
 */
 void Sys_PlatformInit( void )
 {
+	TIMECAPS ptc;
+	UINT res;
+	
 #ifndef DEDICATED
 	const char *SDL_VIDEODRIVER = getenv( "SDL_VIDEODRIVER" );
 
@@ -708,10 +713,38 @@
 	else
 		SDL_VIDEODRIVER_externallySet = qfalse;
 #endif
+
+	if(timeGetDevCaps(&ptc, sizeof(ptc)) == MMSYSERR_NOERROR)
+	{
+		timerResolution = ptc.wPeriodMin;
+
+		if(timerResolution > 1)
+		{
+			Com_Printf("Warning: Minimum supported timer resolution is %ums "
+				"on this system, recommended resolution 1ms\n", timerResolution);
+		}
+		
+		timeBeginPeriod(timerResolution);				
+	}
+	else
+		timerResolution = 0;
 }
 
 /*
 ==============
+Sys_PlatformExit
+
+Windows specific initialisation
+==============
+*/
+void Sys_PlatformExit( void )
+{
+	if(timerResolution)
+		timeEndPeriod(timerResolution);
+}
+
+/*
+==============
 Sys_SetEnv
 
 set/unset environment variables (empty value removes it)



More information about the quake3-commits mailing list