diff options
Diffstat (limited to 'src/sdl/sdl_glimp.c')
-rw-r--r-- | src/sdl/sdl_glimp.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c index 0c765b66..58e9c7ed 100644 --- a/src/sdl/sdl_glimp.c +++ b/src/sdl/sdl_glimp.c @@ -120,8 +120,12 @@ static int GLimp_CompareModes( const void *a, const void *b ) 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 ) - glConfig.displayAspect ); - float aspectDiffB = fabs( ( (float)modeB->w / (float)modeB->h ) - glConfig.displayAspect ); + float aspectA = (float)modeA->w / (float)modeA->h; + float aspectB = (float)modeB->w / (float)modeB->h; + int areaA = modeA->w * modeA->h; + int areaB = modeB->w * modeB->h; + float aspectDiffA = fabs( aspectA - glConfig.displayAspect ); + float aspectDiffB = fabs( aspectB - glConfig.displayAspect ); float aspectDiffsDiff = aspectDiffA - aspectDiffB; if( aspectDiffsDiff > ASPECT_EPSILON ) @@ -129,12 +133,7 @@ static int GLimp_CompareModes( const void *a, const void *b ) else if( aspectDiffsDiff < -ASPECT_EPSILON ) return -1; else - { - if( modeA->w == modeB->w ) - return modeA->h - modeB->h; - else - return modeA->w - modeB->w; - } + return areaA - areaB; } /* @@ -165,8 +164,8 @@ static void GLimp_DetectAvailableModes(void) for( numModes = 0; modes[ numModes ]; numModes++ ); - if(numModes > 1) - qsort( modes+1, numModes-1, sizeof( SDL_Rect* ), GLimp_CompareModes ); + if( numModes > 1 ) + qsort( modes, numModes, sizeof( SDL_Rect* ), GLimp_CompareModes ); for( i = 0; i < numModes; i++ ) { |