diff options
author | Tim Angus <tim@ngus.net> | 2009-11-15 01:10:27 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:17:19 +0000 |
commit | 8f759de26ac1a17676f3937019804b3a9a972e35 (patch) | |
tree | 4182465207276ea0b51051b6e9d6ad992b07f74d /src/sdl | |
parent | 00043d33bad26cedbfa105269ae2b1b66684b721 (diff) |
* s/ITEM_TYPE_COMBO/ITEM_TYPE_CYCLE/
* Add ITEM_TYPE_COMBOBOX -- a proper combobox widget
* Use ITEM_TYPE_COMBOBOX for video mode selection
* General refactoring of the listbox code
* Various other assorted tidy-ups
Diffstat (limited to 'src/sdl')
-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++ ) { |