Look for an exact match first when setting a video mode on BeOS.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 08 Dec 2006 00:31:32 +0000
changeset 208134a4d02b8db1
parent 2080 c611cb0638b2
child 2082 e6cd882e3ac0
Look for an exact match first when setting a video mode on BeOS.

Fixes Bugzilla #370.
src/video/bwindow/SDL_sysvideo.cc
     1.1 --- a/src/video/bwindow/SDL_sysvideo.cc	Fri Dec 08 00:16:38 2006 +0000
     1.2 +++ b/src/video/bwindow/SDL_sysvideo.cc	Fri Dec 08 00:31:32 2006 +0000
     1.3 @@ -370,12 +370,23 @@
     1.4              (current.timing.h_total * current.timing.v_total);
     1.5  
     1.6          modes = SDL_modelist[((bpp + 7) / 8) - 1];
     1.7 -        for (i = 0; modes[i] && (modes[i]->w > width) &&
     1.8 -             (modes[i]->h > height); ++i) {
     1.9 -            /* still looking */
    1.10 +
    1.11 +        bool exactmatch = false;
    1.12 +        for ( uint32 x = 0; modes[x]; x++ ) {
    1.13 +            if (modes[x]->w == width && modes[x]->h == height) {
    1.14 +                exactmatch = true;
    1.15 +                i = x;
    1.16 +                break;
    1.17 +            }
    1.18          }
    1.19 -        if (!modes[i] || (modes[i]->w < width) || (modes[i]->h < height)) {
    1.20 -            --i;                /* We went too far */
    1.21 +        if (!exactmatch) {
    1.22 +            for (i = 0; modes[i] && (modes[i]->w > width) &&
    1.23 +                 (modes[i]->h > height); ++i) {
    1.24 +                /* still looking */
    1.25 +            }
    1.26 +            if (!modes[i] || (modes[i]->w < width) || (modes[i]->h < height)) {
    1.27 +                --i;                /* We went too far */
    1.28 +            }
    1.29          }
    1.30          width = modes[i]->w;
    1.31          height = modes[i]->h;