aboutsummaryrefslogtreecommitdiffstats
path: root/code/sdl
diff options
context:
space:
mode:
authorludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-12-08 10:08:05 +0000
committerludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-12-08 10:08:05 +0000
commitff0cfef33b01b1146306b0f6d81bf3604789c546 (patch)
tree3dccdb7da3de8a03537491ebbb0cb23e2332ccbb /code/sdl
parent4d3e70d7ec32e53b272573f6eef21ab56ca79e01 (diff)
downloadioquake3-aero-ff0cfef33b01b1146306b0f6d81bf3604789c546.tar.gz
ioquake3-aero-ff0cfef33b01b1146306b0f6d81bf3604789c546.zip
detect available resolutions and offer them in the menu
Store the resolutions detected by SDL in a cvar. The mod code can then optionally use the cvar to offer a better choice in the menu. Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de> git-svn-id: svn://svn.icculus.org/quake3/trunk@1231 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/sdl')
-rw-r--r--code/sdl/sdl_glimp.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/code/sdl/sdl_glimp.c b/code/sdl/sdl_glimp.c
index a1e1a27..be2ab18 100644
--- a/code/sdl/sdl_glimp.c
+++ b/code/sdl/sdl_glimp.c
@@ -110,6 +110,46 @@ void GLimp_LogComment( char *comment )
{
}
+static void set_available_modes(void)
+{
+ 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 );
+ }
+}
+
/*
===============
GLimp_SetMode
@@ -275,6 +315,8 @@ static int GLimp_SetMode( int mode, qboolean fullscreen )
break;
}
+ set_available_modes();
+
if (!vidscreen)
{
ri.Printf( PRINT_ALL, "Couldn't get a visual\n" );
@@ -526,6 +568,8 @@ void GLimp_Init( void )
// initialize extensions
GLimp_InitExtensions( );
+ ri.Cvar_Get( "r_availableModes", "", CVAR_ROM );
+
// This depends on SDL_INIT_VIDEO, hence having it here
IN_Init( );