summaryrefslogtreecommitdiff
path: root/src/sdl
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2014-09-20 19:16:08 -0500
committerTim Angus <tim@ngus.net>2015-03-17 11:38:37 +0000
commite1359297afc8fa25af067c7d9c3fe0a59a6012c1 (patch)
treedfb7dc00a5290e44efafe6628fcb12400755f135 /src/sdl
parentdcd45b4c9f0ea05d968beb236c24623b11b802a4 (diff)
Don't add duplicate resolutions to r_availableModes
SDL can give the same resolution with different refresh rates. The refresh rate isn't used, so only add resolution to mode list once.
Diffstat (limited to 'src/sdl')
-rw-r--r--src/sdl/sdl_glimp.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c
index 3b619b1b..a88d9173 100644
--- a/src/sdl/sdl_glimp.c
+++ b/src/sdl/sdl_glimp.c
@@ -133,7 +133,7 @@ GLimp_DetectAvailableModes
*/
static void GLimp_DetectAvailableModes(void)
{
- int i;
+ int i, j;
char buf[ MAX_STRING_CHARS ] = { 0 };
SDL_Rect modes[ 128 ];
int numModes = 0;
@@ -163,6 +163,17 @@ static void GLimp_DetectAvailableModes(void)
if( windowMode.format != mode.format )
continue;
+ // SDL can give the same resolution with different refresh rates.
+ // Only list resolution once.
+ for( j = 0; j < numModes; j++ )
+ {
+ if( mode.w == modes[ j ].w && mode.h == modes[ j ].h )
+ break;
+ }
+
+ if( j != numModes )
+ continue;
+
modes[ numModes ].w = mode.w;
modes[ numModes ].h = mode.h;
numModes++;
@@ -178,7 +189,7 @@ static void GLimp_DetectAvailableModes(void)
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 );
+ ri.Printf( PRINT_WARNING, "Skipping mode %ux%u, buffer too small\n", modes[ i ].w, modes[ i ].h );
}
if( *buf )