aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--code/q3_ui/ui_local.h1
-rw-r--r--code/q3_ui/ui_main.c4
-rw-r--r--code/q3_ui/ui_menu.c7
-rw-r--r--code/q3_ui/ui_video.c193
-rw-r--r--code/renderer/tr_init.c9
-rw-r--r--code/renderer/tr_local.h7
-rw-r--r--code/sdl/sdl_glimp.c131
7 files changed, 213 insertions, 139 deletions
diff --git a/code/q3_ui/ui_local.h b/code/q3_ui/ui_local.h
index 3e1cdf1..20d9f3e 100644
--- a/code/q3_ui/ui_local.h
+++ b/code/q3_ui/ui_local.h
@@ -92,6 +92,7 @@ extern vmCvar_t ui_server16;
extern vmCvar_t ui_cdkey;
extern vmCvar_t ui_cdkeychecked;
+extern vmCvar_t ui_ioq3;
//
diff --git a/code/q3_ui/ui_main.c b/code/q3_ui/ui_main.c
index 734166f..2b10db0 100644
--- a/code/q3_ui/ui_main.c
+++ b/code/q3_ui/ui_main.c
@@ -155,6 +155,7 @@ vmCvar_t ui_server15;
vmCvar_t ui_server16;
vmCvar_t ui_cdkeychecked;
+vmCvar_t ui_ioq3;
static cvarTable_t cvarTable[] = {
{ &ui_ffa_fraglimit, "ui_ffa_fraglimit", "20", CVAR_ARCHIVE },
@@ -212,7 +213,8 @@ static cvarTable_t cvarTable[] = {
{ &ui_server15, "server15", "", CVAR_ARCHIVE },
{ &ui_server16, "server16", "", CVAR_ARCHIVE },
- { &ui_cdkeychecked, "ui_cdkeychecked", "0", CVAR_ROM }
+ { &ui_cdkeychecked, "ui_cdkeychecked", "0", CVAR_ROM },
+ { &ui_ioq3, "ui_ioq3", "1", CVAR_ROM }
};
static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]);
diff --git a/code/q3_ui/ui_menu.c b/code/q3_ui/ui_menu.c
index 46bd74b..73cddd0 100644
--- a/code/q3_ui/ui_menu.c
+++ b/code/q3_ui/ui_menu.c
@@ -222,10 +222,11 @@ static void Main_MenuDraw( void ) {
}
if (uis.demoversion) {
- UI_DrawProportionalString( 320, 412, "DEMO FOR MATURE AUDIENCES DEMO", UI_CENTER|UI_SMALLFONT, color );
+ UI_DrawProportionalString( 320, 372, "DEMO FOR MATURE AUDIENCES DEMO", UI_CENTER|UI_SMALLFONT, color );
+ UI_DrawString( 320, 400, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
+ } else {
+ UI_DrawString( 320, 450, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
}
- UI_DrawString( 320, 440, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color );
- UI_DrawString( 320, 460, "powered by the ioquake3 engine", UI_CENTER|UI_SMALLFONT, color );
}
diff --git a/code/q3_ui/ui_video.c b/code/q3_ui/ui_video.c
index 813b3e8..8f5de7c 100644
--- a/code/q3_ui/ui_video.c
+++ b/code/q3_ui/ui_video.c
@@ -24,66 +24,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
void GraphicsOptions_MenuInit( void );
-static const char *builtin_resolutions[] =
-{
- "320x240",
- "400x300",
- "512x384",
- "640x480",
- "800x600",
- "960x720",
- "1024x768",
- "1152x864",
- "1280x1024",
- "1600x1200",
- "2048x1536",
- "856x480 wide screen",
- NULL
-};
-
-static char resbuf[MAX_STRING_CHARS];
-static const char* detected_resolutions[32];
-
-static const char** reslist = builtin_resolutions;
-static int use_builtin_resolutions = qtrue;
-
-static int det2builtinres(int mode)
-{
- int i;
-
- if(use_builtin_resolutions)
- return mode;
-
- if(mode < 0)
- return -1;
-
- for(i = 0; builtin_resolutions[i]; ++i)
- {
- if(!strcmp(builtin_resolutions[i], detected_resolutions[mode]))
- return i;
- }
- return -1;
-}
-
-static int builtin2detres(int mode)
-{
- int i;
-
- if(use_builtin_resolutions)
- return mode;
-
- if(mode < 0)
- return -1;
-
- for(i = 0; detected_resolutions[i]; ++i)
- {
- if(!strcmp(builtin_resolutions[mode], detected_resolutions[i]))
- return i;
- }
- return -1;
-}
-
-
/*
=======================================================================
@@ -378,6 +318,77 @@ static InitialVideoOptions_s s_ivo_templates[] =
#define NUM_IVO_TEMPLATES ( sizeof( s_ivo_templates ) / sizeof( s_ivo_templates[0] ) )
+static const char *builtinResolutions[ ] =
+{
+ "320x240",
+ "400x300",
+ "512x384",
+ "640x480",
+ "800x600",
+ "960x720",
+ "1024x768",
+ "1152x864",
+ "1280x1024",
+ "1600x1200",
+ "2048x1536",
+ "856x480 wide screen",
+ NULL
+};
+
+static char resbuf[ MAX_STRING_CHARS ];
+static const char* detectedResolutions[ 32 ];
+
+static const char** resolutions = builtinResolutions;
+static qboolean resolutionsDetected = qfalse;
+
+/*
+=================
+GraphicsOptions_FindBuiltinResolution
+=================
+*/
+static int GraphicsOptions_FindBuiltinResolution( int mode )
+{
+ int i;
+
+ if( !resolutionsDetected )
+ return mode;
+
+ if( mode < 0 )
+ return -1;
+
+ for( i = 0; builtinResolutions[ i ]; i++ )
+ {
+ if( !strcmp( builtinResolutions[ i ], detectedResolutions[ mode ] ) )
+ return i;
+ }
+
+ return -1;
+}
+
+/*
+=================
+GraphicsOptions_FindDetectedResolution
+=================
+*/
+static int GraphicsOptions_FindDetectedResolution( int mode )
+{
+ int i;
+
+ if( !resolutionsDetected )
+ return mode;
+
+ if( mode < 0 )
+ return -1;
+
+ for( i = 0; detectedResolutions[ i ]; i++ )
+ {
+ if( !strcmp( builtinResolutions[ mode ], detectedResolutions[ i ] ) )
+ return i;
+ }
+
+ return -1;
+}
+
/*
=================
GraphicsOptions_GetInitialVideo
@@ -541,23 +552,22 @@ static void GraphicsOptions_ApplyChanges( void *unused, int notification )
trap_Cvar_SetValue( "r_picmip", 3 - s_graphicsoptions.tq.curvalue );
trap_Cvar_SetValue( "r_allowExtensions", s_graphicsoptions.allow_extensions.curvalue );
- if(!use_builtin_resolutions)
+ if( resolutionsDetected )
{
// search for builtin mode that matches the detected mode
- int i;
- int mode = s_graphicsoptions.mode.curvalue;
- i = det2builtinres(mode);
- if(i == -1)
+ int mode = GraphicsOptions_FindBuiltinResolution( s_graphicsoptions.mode.curvalue );
+ if( mode == -1 )
{
- char w[16], h[16];
- Q_strncpyz(w, detected_resolutions[mode], sizeof(w));
- *strchr(w, 'x') = 0;
- Q_strncpyz(h, strchr(detected_resolutions[mode], 'x')+1, sizeof(h));
- trap_Cvar_Set( "r_customwidth", w);
- trap_Cvar_Set( "r_customheight", h);
+ char w[ 16 ], h[ 16 ];
+ Q_strncpyz( w, detectedResolutions[ s_graphicsoptions.mode.curvalue ], sizeof( w ) );
+ *strchr( w, 'x' ) = 0;
+ Q_strncpyz( h,
+ strchr( detectedResolutions[ s_graphicsoptions.mode.curvalue ], 'x' ) + 1, sizeof( h ) );
+ trap_Cvar_Set( "r_customwidth", w );
+ trap_Cvar_Set( "r_customheight", h );
}
- trap_Cvar_SetValue( "r_mode", i );
+ trap_Cvar_SetValue( "r_mode", mode );
}
else
trap_Cvar_SetValue( "r_mode", s_graphicsoptions.mode.curvalue );
@@ -695,15 +705,12 @@ GraphicsOptions_SetMenuItems
*/
static void GraphicsOptions_SetMenuItems( void )
{
- s_graphicsoptions.mode.curvalue = trap_Cvar_VariableValue( "r_mode" );
- s_graphicsoptions.mode.curvalue = builtin2detres(s_graphicsoptions.mode.curvalue);
+ s_graphicsoptions.mode.curvalue =
+ GraphicsOptions_FindDetectedResolution( trap_Cvar_VariableValue( "r_mode" ) );
+
if ( s_graphicsoptions.mode.curvalue < 0 )
{
- if(use_builtin_resolutions)
- {
- s_graphicsoptions.mode.curvalue = 3;
- }
- else
+ if( resolutionsDetected )
{
int i;
char buf[MAX_STRING_CHARS];
@@ -712,9 +719,9 @@ static void GraphicsOptions_SetMenuItems( void )
buf[strlen(buf)] = 'x';
trap_Cvar_VariableStringBuffer("r_customheight", buf+strlen(buf), sizeof(buf)-strlen(buf));
- for(i = 0; detected_resolutions[i]; ++i)
+ for(i = 0; detectedResolutions[i]; ++i)
{
- if(!strcmp(buf, detected_resolutions[i]))
+ if(!strcmp(buf, detectedResolutions[i]))
{
s_graphicsoptions.mode.curvalue = i;
break;
@@ -723,6 +730,10 @@ static void GraphicsOptions_SetMenuItems( void )
if ( s_graphicsoptions.mode.curvalue < 0 )
s_graphicsoptions.mode.curvalue = 0;
}
+ else
+ {
+ s_graphicsoptions.mode.curvalue = 3;
+ }
}
s_graphicsoptions.fs.curvalue = trap_Cvar_VariableValue("r_fullscreen");
s_graphicsoptions.allow_extensions.curvalue = trap_Cvar_VariableValue("r_allowExtensions");
@@ -878,18 +889,20 @@ void GraphicsOptions_MenuInit( void )
if(*resbuf)
{
char* s = resbuf;
- unsigned i = 0;
- while( s && i < sizeof(detected_resolutions)/sizeof(detected_resolutions[0])-1)
+ unsigned int i = 0;
+ while( s && i < sizeof(detectedResolutions)/sizeof(detectedResolutions[0])-1)
{
- detected_resolutions[i++] = s;
+ detectedResolutions[i++] = s;
s = strchr(s, ' ');
- if(s) *s++ = '\0';
+ if( s )
+ *s++ = '\0';
}
- detected_resolutions[i] = NULL;
- if(i)
+ detectedResolutions[ i ] = NULL;
+
+ if( i > 0 )
{
- reslist = detected_resolutions;
- use_builtin_resolutions = 0;
+ resolutions = detectedResolutions;
+ resolutionsDetected = qtrue;
}
}
@@ -997,7 +1010,7 @@ void GraphicsOptions_MenuInit( void )
s_graphicsoptions.mode.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_graphicsoptions.mode.generic.x = 400;
s_graphicsoptions.mode.generic.y = y;
- s_graphicsoptions.mode.itemnames = reslist;
+ s_graphicsoptions.mode.itemnames = resolutions;
s_graphicsoptions.mode.generic.callback = GraphicsOptions_Event;
s_graphicsoptions.mode.generic.id = ID_MODE;
y += BIGCHAR_HEIGHT+2;
diff --git a/code/renderer/tr_init.c b/code/renderer/tr_init.c
index 75ffd52..4618917 100644
--- a/code/renderer/tr_init.c
+++ b/code/renderer/tr_init.c
@@ -23,10 +23,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "tr_local.h"
-glconfig_t glConfig;
-qboolean textureFilterAnisotropic = qfalse;
-int maxAnisotropy = 0;
-
+glconfig_t glConfig;
+qboolean textureFilterAnisotropic = qfalse;
+int maxAnisotropy = 0;
+float displayAspect = 0.0f;
+
glstate_t glState;
static void GfxInfo_f( void );
diff --git a/code/renderer/tr_local.h b/code/renderer/tr_local.h
index 7ff50e4..5354bc7 100644
--- a/code/renderer/tr_local.h
+++ b/code/renderer/tr_local.h
@@ -973,9 +973,10 @@ extern glstate_t glState; // outside of TR since it shouldn't be cleared during
// These two variables should live inside glConfig but can't because of compatibility issues to the original ID vms.
// If you release a stand-alone game and your mod uses tr_types.h from this build you can safely move them to
// the glconfig_t struct.
-extern qboolean textureFilterAnisotropic;
-extern int maxAnisotropy;
-
+extern qboolean textureFilterAnisotropic;
+extern int maxAnisotropy;
+extern float displayAspect;
+
//
// cvars
diff --git a/code/sdl/sdl_glimp.c b/code/sdl/sdl_glimp.c
index be2ab18..eeba074 100644
--- a/code/sdl/sdl_glimp.c
+++ b/code/sdl/sdl_glimp.c
@@ -44,6 +44,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <math.h>
#include "../renderer/tr_local.h"
#include "../client/client.h"
@@ -110,44 +111,79 @@ void GLimp_LogComment( char *comment )
{
}
-static void set_available_modes(void)
+/*
+===============
+GLimp_CompareModes
+===============
+*/
+static int GLimp_CompareModes( const void *a, const void *b )
{
- char buf[MAX_STRING_CHARS];
- SDL_Rect **modes;
- size_t len = 0;
- int i;
-
- modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
-
- if (!modes)
- {
- ri.Printf( PRINT_WARNING, "Can't get list of available modes\n");
- return;
- }
-
- if (modes == (SDL_Rect **)-1)
- {
- ri.Printf( PRINT_ALL, "Display supports any resolution\n");
- return; // can set any resolution
- }
-
- for (i = 0; modes[i]; ++i)
- {
- if(snprintf(NULL, 0, "%ux%u ", modes[i]->w, modes[i]->h) < (int)sizeof(buf)-len)
- {
- len += sprintf(buf+len, "%ux%u ", modes[i]->w, modes[i]->h);
- }
- else
- {
- ri.Printf( PRINT_WARNING, "Skipping mode %ux%x, buffer too small\n", modes[i]->w, modes[i]->h);
- }
- }
- if(len)
- {
- buf[strlen(buf)-1] = 0;
- ri.Printf( PRINT_ALL, "Available modes: '%s'\n", buf);
- ri.Cvar_Set( "r_availableModes", buf );
- }
+ const float ASPECT_EPSILON = 0.001f;
+ SDL_Rect *modeA = *(SDL_Rect **)a;
+ SDL_Rect *modeB = *(SDL_Rect **)b;
+ float aspectDiffA = fabs( ( (float)modeA->w / (float)modeA->h ) - displayAspect );
+ float aspectDiffB = fabs( ( (float)modeB->w / (float)modeB->h ) - displayAspect );
+ float aspectDiffsDiff = aspectDiffA - aspectDiffB;
+
+ if( aspectDiffsDiff > ASPECT_EPSILON )
+ return 1;
+ else if( aspectDiffsDiff < -ASPECT_EPSILON )
+ return -1;
+ else
+ {
+ if( modeA->w == modeB->w )
+ return modeA->h - modeB->h;
+ else
+ return modeA->w - modeB->w;
+ }
+}
+
+/*
+===============
+GLimp_DetectAvailableModes
+===============
+*/
+static void GLimp_DetectAvailableModes(void)
+{
+ char buf[ MAX_STRING_CHARS ] = { 0 };
+ SDL_Rect **modes;
+ int numModes;
+ int i;
+
+ modes = SDL_ListModes( NULL, SDL_OPENGL | SDL_FULLSCREEN );
+
+ if( !modes )
+ {
+ ri.Printf( PRINT_WARNING, "Can't get list of available modes\n" );
+ return;
+ }
+
+ if( modes == (SDL_Rect **)-1 )
+ {
+ ri.Printf( PRINT_ALL, "Display supports any resolution\n" );
+ return; // can set any resolution
+ }
+
+ for( numModes = 0; modes[ numModes ]; numModes++ );
+
+ qsort( modes, numModes, sizeof( SDL_Rect* ), GLimp_CompareModes );
+
+ for( i = 0; i < numModes; i++ )
+ {
+ const char *newModeString = va( "%ux%u ", modes[ i ]->w, modes[ i ]->h );
+
+ if( strlen( newModeString ) < (int)sizeof( buf ) - strlen( buf ) )
+ Q_strcat( buf, sizeof( buf ), newModeString );
+ else
+ ri.Printf( PRINT_WARNING, "Skipping mode %ux%x, buffer too small\n", modes[i]->w, modes[i]->h );
+ }
+
+ if( *buf )
+ {
+ buf[ strlen( buf ) - 1 ] = 0;
+ ri.Printf( PRINT_ALL, "Available modes: '%s'\n", buf );
+ ri.Cvar_Set( "r_availableModes", buf );
+ }
}
/*
@@ -164,9 +200,28 @@ static int GLimp_SetMode( int mode, qboolean fullscreen )
int i = 0;
SDL_Surface *vidscreen = NULL;
Uint32 flags = SDL_OPENGL;
+ const SDL_VideoInfo *videoInfo;
ri.Printf( PRINT_ALL, "Initializing OpenGL display\n");
+ if( displayAspect == 0.0f )
+ {
+#if !SDL_VERSION_ATLEAST(1, 2, 10)
+ // 1.2.10 is needed to get the desktop resolution
+ displayAspect = 4.0f / 3.0f;
+#elif MINSDL_PATCH >= 10
+# error Ifdeffery no longer necessary, please remove
+#else
+ // Guess the display aspect ratio through the desktop resolution
+ // by assuming (relatively safely) that it is set at or close to
+ // the display's native aspect ratio
+ videoInfo = SDL_GetVideoInfo( );
+ displayAspect = (float)videoInfo->current_w / (float)videoInfo->current_h;
+#endif
+
+ ri.Printf( PRINT_ALL, "Estimated display aspect: %.3f\n", displayAspect );
+ }
+
ri.Printf (PRINT_ALL, "...setting mode %d:", mode );
if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) )
@@ -315,7 +370,7 @@ static int GLimp_SetMode( int mode, qboolean fullscreen )
break;
}
- set_available_modes();
+ GLimp_DetectAvailableModes();
if (!vidscreen)
{