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.
This commit is contained in:
Zack Middleton 2014-09-20 19:16:08 -05:00
parent 9fbbf4214d
commit 24923615b7
1 changed files with 13 additions and 2 deletions

View File

@ -128,7 +128,7 @@ GLimp_DetectAvailableModes
*/ */
static void GLimp_DetectAvailableModes(void) static void GLimp_DetectAvailableModes(void)
{ {
int i; int i, j;
char buf[ MAX_STRING_CHARS ] = { 0 }; char buf[ MAX_STRING_CHARS ] = { 0 };
SDL_Rect modes[ 128 ]; SDL_Rect modes[ 128 ];
int numModes = 0; int numModes = 0;
@ -158,6 +158,17 @@ static void GLimp_DetectAvailableModes(void)
if( windowMode.format != mode.format ) if( windowMode.format != mode.format )
continue; 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 ].w = mode.w;
modes[ numModes ].h = mode.h; modes[ numModes ].h = mode.h;
numModes++; numModes++;
@ -173,7 +184,7 @@ static void GLimp_DetectAvailableModes(void)
if( strlen( newModeString ) < (int)sizeof( buf ) - strlen( buf ) ) if( strlen( newModeString ) < (int)sizeof( buf ) - strlen( buf ) )
Q_strcat( buf, sizeof( buf ), newModeString ); Q_strcat( buf, sizeof( buf ), newModeString );
else 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 ) if( *buf )