summaryrefslogtreecommitdiff
path: root/src/sdl
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-03 11:52:53 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:28 +0000
commitb47a49a03370e7ea42f47623b9f72a5ca799f0e7 (patch)
tree9d64d778ded2971d7ebd05970d903d886bd81436 /src/sdl
parent09ceb08b95978feb0a9b737f22ac0f662c7465d6 (diff)
* Merge ioq3-r1423
+ IPv6 + VoIP + Stereo rendering + Other minor stuff
Diffstat (limited to 'src/sdl')
-rw-r--r--src/sdl/sdl_glimp.c80
-rw-r--r--src/sdl/sdl_input.c38
2 files changed, 96 insertions, 22 deletions
diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c
index 57f3c353..068ab02c 100644
--- a/src/sdl/sdl_glimp.c
+++ b/src/sdl/sdl_glimp.c
@@ -169,7 +169,8 @@ static void GLimp_DetectAvailableModes(void)
for( numModes = 0; modes[ numModes ]; numModes++ );
- qsort( modes, numModes, sizeof( SDL_Rect* ), GLimp_CompareModes );
+ if(numModes > 1)
+ qsort( modes+1, numModes-1, sizeof( SDL_Rect* ), GLimp_CompareModes );
for( i = 0; i < numModes; i++ )
{
@@ -334,6 +335,18 @@ static int GLimp_SetMode( qboolean failSafe, qboolean fullscreen )
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, sdlcolorbits );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, tdepthbits );
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, tstencilbits );
+
+ if(r_stereoEnabled->integer)
+ {
+ glConfig.stereoEnabled = qtrue;
+ SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
+ }
+ else
+ {
+ glConfig.stereoEnabled = qfalse;
+ SDL_GL_SetAttribute(SDL_GL_STEREO, 0);
+ }
+
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
#if 0 // See http://bugzilla.icculus.org/show_bug.cgi?id=3526
@@ -451,6 +464,17 @@ static qboolean GLimp_StartDriverAndSetMode( qboolean failSafe, qboolean fullscr
return qtrue;
}
+
+static qboolean GLimp_HaveExtension(const char *ext)
+{
+ const char *ptr = Q_stristr( glConfig.extensions_string, ext );
+ if (ptr == NULL)
+ return qfalse;
+ ptr += strlen(ext);
+ return ((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string.
+}
+
+
/*
===============
GLimp_InitExtensions
@@ -466,29 +490,52 @@ static void GLimp_InitExtensions( void )
ri.Printf( PRINT_ALL, "Initializing OpenGL extensions\n" );
- // GL_S3_s3tc
- if ( Q_stristr( glConfig.extensions_string, "GL_S3_s3tc" ) )
+ glConfig.textureCompression = TC_NONE;
+
+ // GL_EXT_texture_compression_s3tc
+ if ( GLimp_HaveExtension( "GL_ARB_texture_compression" ) &&
+ GLimp_HaveExtension( "GL_EXT_texture_compression_s3tc" ) )
{
if ( r_ext_compressed_textures->value )
{
- glConfig.textureCompression = TC_S3TC;
- ri.Printf( PRINT_ALL, "...using GL_S3_s3tc\n" );
+ glConfig.textureCompression = TC_S3TC_ARB;
+ ri.Printf( PRINT_ALL, "...using GL_EXT_texture_compression_s3tc\n" );
}
else
{
- glConfig.textureCompression = TC_NONE;
- ri.Printf( PRINT_ALL, "...ignoring GL_S3_s3tc\n" );
+ ri.Printf( PRINT_ALL, "...ignoring GL_EXT_texture_compression_s3tc\n" );
}
}
else
{
- glConfig.textureCompression = TC_NONE;
- ri.Printf( PRINT_ALL, "...GL_S3_s3tc not found\n" );
+ ri.Printf( PRINT_ALL, "...GL_EXT_texture_compression_s3tc not found\n" );
}
+ // GL_S3_s3tc ... legacy extension before GL_EXT_texture_compression_s3tc.
+ if (glConfig.textureCompression == TC_NONE)
+ {
+ if ( GLimp_HaveExtension( "GL_S3_s3tc" ) )
+ {
+ if ( r_ext_compressed_textures->value )
+ {
+ glConfig.textureCompression = TC_S3TC;
+ ri.Printf( PRINT_ALL, "...using GL_S3_s3tc\n" );
+ }
+ else
+ {
+ ri.Printf( PRINT_ALL, "...ignoring GL_S3_s3tc\n" );
+ }
+ }
+ else
+ {
+ ri.Printf( PRINT_ALL, "...GL_S3_s3tc not found\n" );
+ }
+ }
+
+
// GL_EXT_texture_env_add
glConfig.textureEnvAddAvailable = qfalse;
- if ( Q_stristr( glConfig.extensions_string, "EXT_texture_env_add" ) )
+ if ( GLimp_HaveExtension( "EXT_texture_env_add" ) )
{
if ( r_ext_texture_env_add->integer )
{
@@ -510,7 +557,7 @@ static void GLimp_InitExtensions( void )
qglMultiTexCoord2fARB = NULL;
qglActiveTextureARB = NULL;
qglClientActiveTextureARB = NULL;
- if ( Q_stristr( glConfig.extensions_string, "GL_ARB_multitexture" ) )
+ if ( GLimp_HaveExtension( "GL_ARB_multitexture" ) )
{
if ( r_ext_multitexture->value )
{
@@ -547,7 +594,7 @@ static void GLimp_InitExtensions( void )
}
// GL_EXT_compiled_vertex_array
- if ( Q_stristr( glConfig.extensions_string, "GL_EXT_compiled_vertex_array" ) )
+ if ( GLimp_HaveExtension( "GL_EXT_compiled_vertex_array" ) )
{
if ( r_ext_compiled_vertex_array->value )
{
@@ -570,7 +617,7 @@ static void GLimp_InitExtensions( void )
}
glConfig.textureFilterAnisotropic = qfalse;
- if ( strstr( glConfig.extensions_string, "GL_EXT_texture_filter_anisotropic" ) )
+ if ( GLimp_HaveExtension( "GL_EXT_texture_filter_anisotropic" ) )
{
if ( r_ext_texture_filter_anisotropic->integer ) {
qglGetIntegerv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, (GLint *)&glConfig.maxAnisotropy );
@@ -672,6 +719,13 @@ void GLimp_EndFrame( void )
fullscreen = qtrue;
else
fullscreen = qfalse;
+
+ if (r_fullscreen->integer && Cvar_VariableIntegerValue( "in_nograb" ))
+ {
+ ri.Printf( PRINT_ALL, "Fullscreen not allowed with in_nograb 1\n");
+ ri.Cvar_Set( "r_fullscreen", "0" );
+ r_fullscreen->modified = qfalse;
+ }
// Is the state we want different from the current state?
if( !!r_fullscreen->integer != fullscreen )
diff --git a/src/sdl/sdl_input.c b/src/sdl/sdl_input.c
index ddff11b4..f7cb0d85 100644
--- a/src/sdl/sdl_input.c
+++ b/src/sdl/sdl_input.c
@@ -42,6 +42,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
#ifdef MACOS_X_ACCELERATION_HACK
+#include <IOKit/IOTypes.h>
#include <IOKit/hidsystem/IOHIDLib.h>
#include <IOKit/hidsystem/IOHIDParameter.h>
#include <IOKit/hidsystem/event_status_driver.h>
@@ -135,7 +136,8 @@ static const char *IN_TranslateSDLToQ3Key(SDL_keysym *keysym, int *key)
case SDLK_RCTRL: *key = K_CTRL; break;
case SDLK_RMETA:
- case SDLK_LMETA:
+ case SDLK_LMETA: *key = K_COMMAND; break;
+
case SDLK_RALT:
case SDLK_LALT: *key = K_ALT; break;
@@ -218,7 +220,7 @@ static void IN_PrintKey(const SDL_Event* event)
IN_GetIOHandle
===============
*/
-static io_connect_t IN_GetIOHandle() // mac os x mouse accel hack
+static io_connect_t IN_GetIOHandle(void) // mac os x mouse accel hack
{
io_connect_t iohandle = MACH_PORT_NULL;
kern_return_t status;
@@ -287,18 +289,17 @@ static void IN_ActivateMouse( void )
if( !mouseActive )
{
- SDL_WM_GrabInput( SDL_GRAB_ON );
SDL_ShowCursor( 0 );
-
#ifdef MACOS_X_CURSOR_HACK
// This is a bug in the current SDL/macosx...have to toggle it a few
// times to get the cursor to hide.
SDL_ShowCursor( 1 );
SDL_ShowCursor( 0 );
#endif
+ SDL_WM_GrabInput( SDL_GRAB_ON );
}
- // in_nograb makes no sense unless fullscreen
+ // in_nograb makes no sense in fullscreen mode
if( !r_fullscreen->integer )
{
if( in_nograb->modified || !mouseActive )
@@ -346,8 +347,9 @@ static void IN_DeactivateMouse( void )
if( mouseActive )
{
- SDL_ShowCursor( 1 );
SDL_WM_GrabInput( SDL_GRAB_OFF );
+ SDL_WarpMouse( glConfig.vidWidth >> 1, glConfig.vidHeight >> 1 );
+ SDL_ShowCursor( 1 );
mouseActive = qfalse;
}
@@ -651,6 +653,7 @@ static void IN_ProcessEvents( void )
SDL_Event e;
const char *p = NULL;
int key = 0;
+ int mx = 0, my = 0;
if( !SDL_WasInit( SDL_INIT_VIDEO ) )
return;
@@ -691,7 +694,10 @@ static void IN_ProcessEvents( void )
case SDL_MOUSEMOTION:
if (mouseActive)
- Com_QueueEvent( 0, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL );
+ {
+ mx += e.motion.xrel;
+ my += e.motion.yrel;
+ }
break;
case SDL_MOUSEBUTTONDOWN:
@@ -714,6 +720,15 @@ 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;
@@ -722,6 +737,9 @@ static void IN_ProcessEvents( void )
break;
}
}
+
+ if(mx || my)
+ Com_QueueEvent( 0, SE_MOUSE, mx, my, 0, NULL );
}
/*
@@ -733,8 +751,10 @@ void IN_Frame (void)
{
IN_JoyMove( );
- // Release the mouse if the console if down and we're windowed
- if( ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) && !r_fullscreen->integer )
+ // Release the mouse if the console is down in windowed mode
+ // or if the window loses focus due to task switching
+ if( ( ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) && !r_fullscreen->integer ) ||
+ !( SDL_GetAppState() & SDL_APPINPUTFOCUS ) )
IN_DeactivateMouse( );
else
IN_ActivateMouse( );