- int num_displays = SDL_GetNumVideoDisplays();
-
- if (num_displays > 0)
- {
- // currently only display modes of first display supported
- int num_modes = SDL_GetNumDisplayModes(0);
-
- if (num_modes > 0)
- {
- modes = checked_calloc((num_modes + 1) * sizeof(SDL_Rect *));
-
- for (i = 0; i < num_modes; i++)
- {
- SDL_DisplayMode mode;
-
- if (SDL_GetDisplayMode(0, i, &mode) < 0)
- break;
-
- modes[i] = checked_calloc(sizeof(SDL_Rect));
-
- modes[i]->w = mode.w;
- modes[i]->h = mode.h;
- }
- }
- }
-#else
- /* get available hardware supported fullscreen modes */
- modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
-#endif
-
- if (modes == NULL)
- {
- /* no hardware screen modes available => no fullscreen mode support */
- // video.fullscreen_available = FALSE;
- hardware_fullscreen_available = FALSE;
- }
- else if (modes == (SDL_Rect **)-1)
- {
- /* fullscreen resolution is not restricted -- all resolutions available */
- video.fullscreen_modes = checked_calloc(2 * sizeof(struct ScreenModeInfo));
-
- /* use native video buffer size for fullscreen mode */
- video.fullscreen_modes[0].width = video.width;
- video.fullscreen_modes[0].height = video.height;
-
- video.fullscreen_modes[1].width = -1;
- video.fullscreen_modes[1].height = -1;
- }
- else
- {
- /* in this case, a certain number of screen modes is available */
- int num_modes = 0;
-
- for (i = 0; modes[i] != NULL; i++)
- {
- boolean found_mode = FALSE;
-
- /* screen mode is smaller than video buffer size -- skip it */
- if (modes[i]->w < video.width || modes[i]->h < video.height)
- continue;
-
- if (video.fullscreen_modes != NULL)
- for (j = 0; video.fullscreen_modes[j].width != -1; j++)
- if (modes[i]->w == video.fullscreen_modes[j].width &&
- modes[i]->h == video.fullscreen_modes[j].height)
- found_mode = TRUE;
-
- if (found_mode) /* screen mode already stored -- skip it */
- continue;
-
- /* new mode found; add it to list of available fullscreen modes */
-
- num_modes++;
-
- video.fullscreen_modes = checked_realloc(video.fullscreen_modes,
- (num_modes + 1) *
- sizeof(struct ScreenModeInfo));
-
- video.fullscreen_modes[num_modes - 1].width = modes[i]->w;
- video.fullscreen_modes[num_modes - 1].height = modes[i]->h;
-
- video.fullscreen_modes[num_modes].width = -1;
- video.fullscreen_modes[num_modes].height = -1;
- }
-
- if (num_modes == 0)
- {
- /* no appropriate screen modes available => no fullscreen mode support */
- // video.fullscreen_available = FALSE;
- hardware_fullscreen_available = FALSE;
- }
- }
-
- video.fullscreen_available = hardware_fullscreen_available;
-
-#if USE_DESKTOP_FULLSCREEN
- // in SDL 2.0, there is always support for desktop fullscreen mode
- // (in SDL 1.2, there is only support for "real" fullscreen mode)