summaryrefslogtreecommitdiff
path: root/src/sdl/sdl_glimp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdl/sdl_glimp.c')
-rw-r--r--src/sdl/sdl_glimp.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c
index fac67a54..0c7bace9 100644
--- a/src/sdl/sdl_glimp.c
+++ b/src/sdl/sdl_glimp.c
@@ -189,12 +189,15 @@ static void GLimp_DetectAvailableModes(void)
}
}
+#define R_FAILSAFE_WIDTH 640
+#define R_FAILSAFE_HEIGHT 480
+
/*
===============
GLimp_SetMode
===============
*/
-static int GLimp_SetMode( int mode, qboolean fullscreen )
+static int GLimp_SetMode( qboolean failSafe, qboolean fullscreen )
{
const char* glstring;
int sdlcolorbits;
@@ -225,14 +228,27 @@ static int GLimp_SetMode( int mode, qboolean fullscreen )
ri.Printf( PRINT_ALL, "Estimated display aspect: %.3f\n", glConfig.displayAspect );
}
- ri.Printf (PRINT_ALL, "...setting mode %d:", mode );
-
- if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) )
+ if( !failSafe )
{
- ri.Printf( PRINT_ALL, " invalid mode\n" );
- return RSERR_INVALID_MODE;
+ glConfig.vidWidth = r_width->integer;
+ glConfig.vidHeight = r_height->integer;
+ glConfig.windowAspect = r_width->value /
+ ( r_height->value * r_pixelAspect->value );
}
- ri.Printf( PRINT_ALL, " %d %d\n", glConfig.vidWidth, glConfig.vidHeight);
+ else if( glConfig.vidWidth != R_FAILSAFE_WIDTH &&
+ glConfig.vidHeight != R_FAILSAFE_HEIGHT )
+ {
+ ri.Printf( PRINT_ALL, "Setting mode %dx%d failed, falling back on mode %dx%d\n",
+ glConfig.vidWidth, glConfig.vidHeight, R_FAILSAFE_WIDTH, R_FAILSAFE_HEIGHT );
+
+ glConfig.vidWidth = R_FAILSAFE_WIDTH;
+ glConfig.vidHeight = R_FAILSAFE_HEIGHT;
+ glConfig.windowAspect = 1.0f;
+ }
+ else
+ return RSERR_INVALID_MODE;
+
+ ri.Printf (PRINT_ALL, "...setting mode %dx%d\n", glConfig.vidWidth, glConfig.vidHeight);
if (fullscreen)
{
@@ -394,7 +410,7 @@ static int GLimp_SetMode( int mode, qboolean fullscreen )
GLimp_StartDriverAndSetMode
===============
*/
-static qboolean GLimp_StartDriverAndSetMode( int mode, qboolean fullscreen )
+static qboolean GLimp_StartDriverAndSetMode( qboolean failSafe, qboolean fullscreen )
{
rserr_t err;
@@ -417,7 +433,7 @@ static qboolean GLimp_StartDriverAndSetMode( int mode, qboolean fullscreen )
fullscreen = qfalse;
}
- err = GLimp_SetMode( mode, fullscreen );
+ err = GLimp_SetMode( failSafe, fullscreen );
switch ( err )
{
@@ -425,7 +441,7 @@ static qboolean GLimp_StartDriverAndSetMode( int mode, qboolean fullscreen )
ri.Printf( PRINT_ALL, "...WARNING: fullscreen unavailable in this mode\n" );
return qfalse;
case RSERR_INVALID_MODE:
- ri.Printf( PRINT_ALL, "...WARNING: could not set the given mode (%d)\n", mode );
+ ri.Printf( PRINT_ALL, "...WARNING: could not set the given mode\n" );
return qfalse;
default:
break;
@@ -577,8 +593,6 @@ static void GLimp_InitExtensions( void )
}
}
-#define R_MODE_FALLBACK 3 // 640 * 480
-
/*
===============
GLimp_Init
@@ -594,16 +608,9 @@ void GLimp_Init( void )
r_allowSoftwareGL = ri.Cvar_Get( "r_allowSoftwareGL", "0", CVAR_LATCH );
// create the window and set up the context
- if( !GLimp_StartDriverAndSetMode( r_mode->integer, r_fullscreen->integer ) )
+ if( !GLimp_StartDriverAndSetMode( qfalse, r_fullscreen->integer ) )
{
- if( r_mode->integer != R_MODE_FALLBACK )
- {
- ri.Printf( PRINT_ALL, "Setting r_mode %d failed, falling back on r_mode %d\n",
- r_mode->integer, R_MODE_FALLBACK );
- if( !GLimp_StartDriverAndSetMode( R_MODE_FALLBACK, r_fullscreen->integer ) )
- success = qfalse;
- }
- else
+ if( !GLimp_StartDriverAndSetMode( qtrue, r_fullscreen->integer ) )
success = qfalse;
}