959 |
|
int max_width = 640, max_height = 480; |
960 |
|
SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); |
961 |
|
if (modes && modes != (SDL_Rect **)-1) { |
962 |
< |
max_width = modes[0]->w; |
963 |
< |
max_height = modes[0]->h; |
962 |
> |
// It turns out that on some implementations, and contrary to the documentation, |
963 |
> |
// the returned list is not sorted from largest to smallest (e.g. Windows) |
964 |
> |
for (int i = 0; modes[i] != NULL; i++) { |
965 |
> |
const int w = modes[i]->w; |
966 |
> |
const int h = modes[i]->h; |
967 |
> |
if (w > max_width && h > max_height) { |
968 |
> |
max_width = w; |
969 |
> |
max_height = h; |
970 |
> |
} |
971 |
> |
} |
972 |
|
if (default_width > max_width) |
973 |
|
default_width = max_width; |
974 |
|
if (default_height > max_height) |