Browse Source

Prefer higher color depths in SDL_GetClosestFullscreenDisplayMode()

(cherry picked from commit 9fa9edeadb846722429994a797ce293a30ec684d)
Anders Jenbo 2 weeks ago
parent
commit
525842f2e7
1 changed files with 10 additions and 5 deletions
  1. 10 5
      src/video/SDL_video.c

+ 10 - 5
src/video/SDL_video.c

@@ -1420,11 +1420,16 @@ bool SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h,
                 continue;
                 continue;
             }
             }
 
 
-            if (mode->w == closest->w && mode->h == closest->h &&
-                SDL_fabsf(closest->refresh_rate - refresh_rate) < SDL_fabsf(mode->refresh_rate - refresh_rate)) {
-                /* We already found a mode and the new mode is further from our
-                 * refresh rate target */
-                continue;
+            if (mode->w == closest->w && mode->h == closest->h) {
+                if (SDL_fabsf(closest->refresh_rate - refresh_rate) < SDL_fabsf(mode->refresh_rate - refresh_rate)) {
+                    /* We already found a mode and the new mode is further from our
+                     * refresh rate target */
+                    continue;
+                }
+                if (SDL_BYTESPERPIXEL(closest->format) >= SDL_BYTESPERPIXEL(mode->format)) {
+                    // Prefer the highest color depth
+                    continue;
+                }
             }
             }
         }
         }