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 2081 34a4d02b8db1
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
--- a/src/video/bwindow/SDL_sysvideo.cc	Fri Dec 08 00:16:38 2006 +0000
+++ b/src/video/bwindow/SDL_sysvideo.cc	Fri Dec 08 00:31:32 2006 +0000
@@ -370,12 +370,23 @@
             (current.timing.h_total * current.timing.v_total);
 
         modes = SDL_modelist[((bpp + 7) / 8) - 1];
-        for (i = 0; modes[i] && (modes[i]->w > width) &&
-             (modes[i]->h > height); ++i) {
-            /* still looking */
+
+        bool exactmatch = false;
+        for ( uint32 x = 0; modes[x]; x++ ) {
+            if (modes[x]->w == width && modes[x]->h == height) {
+                exactmatch = true;
+                i = x;
+                break;
+            }
         }
-        if (!modes[i] || (modes[i]->w < width) || (modes[i]->h < height)) {
-            --i;                /* We went too far */
+        if (!exactmatch) {
+            for (i = 0; modes[i] && (modes[i]->w > width) &&
+                 (modes[i]->h > height); ++i) {
+                /* still looking */
+            }
+            if (!modes[i] || (modes[i]->w < width) || (modes[i]->h < height)) {
+                --i;                /* We went too far */
+            }
         }
         width = modes[i]->w;
         height = modes[i]->h;