r1440 - in trunk/code: sdl sys

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Aug 8 17:35:34 EDT 2008


Author: tma
Date: 2008-08-08 17:35:33 -0400 (Fri, 08 Aug 2008)
New Revision: 1440

Modified:
   trunk/code/sdl/sdl_glimp.c
   trunk/code/sys/sys_local.h
   trunk/code/sys/sys_main.c
   trunk/code/sys/sys_unix.c
   trunk/code/sys/sys_win32.c
Log:
* Add Sys_GLimpInit for platform specific GLimp initialisation
* Move Unix specific signal handlers to Sys_PlatformInit
* (Windows only) Don't set the SDL video driver if SDL_VIDEODRIVER is already
  set externally
* (Windows only) Use the "windib" SDL video driver if in_mouse is set to -1


Modified: trunk/code/sdl/sdl_glimp.c
===================================================================
--- trunk/code/sdl/sdl_glimp.c	2008-08-08 18:27:06 UTC (rev 1439)
+++ trunk/code/sdl/sdl_glimp.c	2008-08-08 21:35:33 UTC (rev 1440)
@@ -416,7 +416,8 @@
 
 		if (SDL_Init(SDL_INIT_VIDEO) == -1)
 		{
-			ri.Printf( PRINT_ALL, "SDL_Init FAILED (%s)\n", SDL_GetError());
+			ri.Printf( PRINT_ALL, "SDL_Init( SDL_INIT_VIDEO ) FAILED (%s)\n",
+					SDL_GetError());
 			return qfalse;
 		}
 
@@ -642,6 +643,8 @@
 
 	r_allowSoftwareGL = ri.Cvar_Get( "r_allowSoftwareGL", "0", CVAR_LATCH );
 
+	Sys_GLimpInit( );
+
 	// create the window and set up the context
 	if( !GLimp_StartDriverAndSetMode( r_mode->integer, r_fullscreen->integer ) )
 	{
@@ -679,8 +682,6 @@
 
 	// This depends on SDL_INIT_VIDEO, hence having it here
 	IN_Init( );
-
-	return;
 }
 
 

Modified: trunk/code/sys/sys_local.h
===================================================================
--- trunk/code/sys/sys_local.h	2008-08-08 18:27:06 UTC (rev 1439)
+++ trunk/code/sys/sys_local.h	2008-08-08 21:35:33 UTC (rev 1440)
@@ -47,6 +47,7 @@
 char *Sys_StripAppBundle( char *pwd );
 #endif
 
+void Sys_GLimpInit( void );
 void Sys_PlatformInit( void );
 void Sys_SigHandler( int signal );
 void Sys_ErrorDialog( const char *error );

Modified: trunk/code/sys/sys_main.c
===================================================================
--- trunk/code/sys/sys_main.c	2008-08-08 18:27:06 UTC (rev 1439)
+++ trunk/code/sys/sys_main.c	2008-08-08 21:35:33 UTC (rev 1440)
@@ -551,16 +551,6 @@
 
 	CON_Init( );
 
-#ifndef _WIN32
-	// Windows doesn't have these signals
-	// see CON_CtrlHandler() in con_win32.c
-	signal( SIGHUP, Sys_SigHandler );
-	signal( SIGQUIT, Sys_SigHandler );
-	signal( SIGTRAP, Sys_SigHandler );
-	signal( SIGIOT, Sys_SigHandler );
-	signal( SIGBUS, Sys_SigHandler );
-#endif
-
 	signal( SIGILL, Sys_SigHandler );
 	signal( SIGFPE, Sys_SigHandler );
 	signal( SIGSEGV, Sys_SigHandler );

Modified: trunk/code/sys/sys_unix.c
===================================================================
--- trunk/code/sys/sys_unix.c	2008-08-08 18:27:06 UTC (rev 1439)
+++ trunk/code/sys/sys_unix.c	2008-08-08 21:35:33 UTC (rev 1440)
@@ -24,6 +24,7 @@
 #include "../qcommon/qcommon.h"
 #include "sys_local.h"
 
+#include <signal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
@@ -514,6 +515,18 @@
 
 /*
 ==============
+Sys_GLimpInit
+
+Unix specific GL implementation initialisation
+==============
+*/
+void Sys_GLimpInit( void )
+{
+	// NOP
+}
+
+/*
+==============
 Sys_PlatformInit
 
 Unix specific initialisation
@@ -521,5 +534,9 @@
 */
 void Sys_PlatformInit( void )
 {
-	// NOP
+	signal( SIGHUP, Sys_SigHandler );
+	signal( SIGQUIT, Sys_SigHandler );
+	signal( SIGTRAP, Sys_SigHandler );
+	signal( SIGIOT, Sys_SigHandler );
+	signal( SIGBUS, Sys_SigHandler );
 }

Modified: trunk/code/sys/sys_win32.c
===================================================================
--- trunk/code/sys/sys_win32.c	2008-08-08 18:27:06 UTC (rev 1439)
+++ trunk/code/sys/sys_win32.c	2008-08-08 21:35:33 UTC (rev 1440)
@@ -577,8 +577,42 @@
 	}
 }
 
+#ifndef DEDICATED
+static qboolean SDL_VIDEODRIVER_externallySet = qfalse;
+#endif
+
 /*
 ==============
+Sys_GLimpInit
+
+Windows specific GL implementation initialisation
+==============
+*/
+void Sys_GLimpInit( void )
+{
+#ifndef DEDICATED
+	if( !SDL_VIDEODRIVER_externallySet )
+	{
+		// It's a little bit weird having in_mouse control the
+		// video driver, but from ioq3's point of view they're
+		// virtually the same except for the mouse input anyway
+		if( Cvar_VariableIntegerValue( "in_mouse" ) == -1 )
+		{
+			// Use the windib SDL backend, which is closest to
+			// the behaviour of idq3 with in_mouse set to -1
+			_putenv( "SDL_VIDEODRIVER=windib" );
+		}
+		else
+		{
+			// Use the DirectX SDL backend
+			_putenv( "SDL_VIDEODRIVER=directx" );
+		}
+	}
+#endif
+}
+
+/*
+==============
 Sys_PlatformInit
 
 Windows specific initialisation
@@ -587,7 +621,15 @@
 void Sys_PlatformInit( void )
 {
 #ifndef DEDICATED
-	// Force the DirectX SDL backend to be used
-	_putenv( "SDL_VIDEODRIVER=directx" );
+	const char *SDL_VIDEODRIVER = getenv( "SDL_VIDEODRIVER" );
+
+	if( SDL_VIDEODRIVER )
+	{
+		Com_Printf( "SDL_VIDEODRIVER is externally set to \"%s\", "
+				"in_mouse -1 will have no effect\n", SDL_VIDEODRIVER );
+		SDL_VIDEODRIVER_externallySet = qtrue;
+	}
+	else
+		SDL_VIDEODRIVER_externallySet = qfalse;
 #endif
 }




More information about the quake3-commits mailing list