From ae6555fd460afa975b8f6d2d450de5c7610b8332 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sat, 19 Mar 2005 05:34:15 +0000 Subject: [PATCH] SDL_ListModes() sometimes does not return a sorted list from largest to smallest screen dimensions (e.g. on windows) --- BasiliskII/src/SDL/video_sdl.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp index 0260eee4..9b32e2fa 100644 --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -959,8 +959,16 @@ bool VideoInit(bool classic) int max_width = 640, max_height = 480; SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); if (modes && modes != (SDL_Rect **)-1) { - max_width = modes[0]->w; - max_height = modes[0]->h; + // It turns out that on some implementations, and contrary to the documentation, + // the returned list is not sorted from largest to smallest (e.g. Windows) + for (int i = 0; modes[i] != NULL; i++) { + const int w = modes[i]->w; + const int h = modes[i]->h; + if (w > max_width && h > max_height) { + max_width = w; + max_height = h; + } + } if (default_width > max_width) default_width = max_width; if (default_height > max_height)