+
+ /* get available hardware supported fullscreen modes */
+ modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
+
+ if (modes == NULL)
+ {
+ /* no screen modes available => no fullscreen mode support */
+ video.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;
+ }
+ }
+
+ /* set window icon */
+ SDLSetWindowIcon(program.sdl_icon_filename);