summaryrefslogtreecommitdiff
path: root/src/sdl
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-03 11:27:22 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:00 +0000
commitf65675275f974129c76249e374b5423a2a444acd (patch)
tree1da97a1bd26d179ad9da2342df8060638d24ef8a /src/sdl
parente5d4b2471e72ff574ebc0d01afbab50fc447cf5a (diff)
* s/r_custom/r_/
* Remove r_mode, making r_width and r_height the only way to choose resolution * Add UI code to parse the detected resolutions list * Make ITEM_TYPE_COMBO do something; basically an ITEM_TYPE_MULTI which is populated by a feeder. A proper combobox widget would be better... in the future maybe * Improve keyboard/mouse button control on ITEM_TYPE_MULTI * Change resolution selection in options menu to use an ITEM_TYPE_COMBO fed by FEEDER_RESOLUTIONS
Diffstat (limited to 'src/sdl')
-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;
}