Passing NULL to SDL_SetDisplayMode() will set the desktop mode. SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Sat, 24 Jun 2006 17:01:29 +0000
branchSDL-1.3
changeset 170757ce47f033a5
parent 1706 1577404809f0
child 1708 cd14138a8703
Passing NULL to SDL_SetDisplayMode() will set the desktop mode.
include/SDL_video.h
src/video/SDL_video.c
test/testsprite2.c
     1.1 --- a/include/SDL_video.h	Sat Jun 24 16:51:01 2006 +0000
     1.2 +++ b/include/SDL_video.h	Sat Jun 24 17:01:29 2006 +0000
     1.3 @@ -458,7 +458,7 @@
     1.4   *
     1.5   * \brief Set up the closest available mode on the current display.
     1.6   *
     1.7 - * \param mode The desired display mode
     1.8 + * \param mode The desired display mode, or NULL to set the desktop mode.
     1.9   *
    1.10   * \return 0 on success, or -1 if setting the display mode failed.
    1.11   */
     2.1 --- a/src/video/SDL_video.c	Sat Jun 24 16:51:01 2006 +0000
     2.2 +++ b/src/video/SDL_video.c	Sat Jun 24 17:01:29 2006 +0000
     2.3 @@ -534,10 +534,8 @@
     2.4          return -1;
     2.5      }
     2.6  
     2.7 -    /* Make sure there's an actual display mode to set */
     2.8      if (!mode) {
     2.9 -        SDL_SetError("No mode passed to SDL_SetDisplayMode");
    2.10 -        return -1;
    2.11 +        mode = SDL_GetDesktopDisplayMode();
    2.12      }
    2.13      display = &SDL_CurrentDisplay;
    2.14      display_mode = *mode;
     3.1 --- a/test/testsprite2.c	Sat Jun 24 16:51:01 2006 +0000
     3.2 +++ b/test/testsprite2.c	Sat Jun 24 17:01:29 2006 +0000
     3.3 @@ -155,22 +155,10 @@
     3.4          }
     3.5      }
     3.6  
     3.7 -    /* Initialize the video mode, if necessary */
     3.8 -    current_mode = SDL_GetCurrentDisplayMode();
     3.9 -    if (!current_mode->w || !current_mode->h) {
    3.10 -        SDL_DisplayMode mode;
    3.11 -
    3.12 -        /* Let the driver pick something it likes, we don't care */
    3.13 -        mode.format = 0;
    3.14 -        mode.w = 0;
    3.15 -        mode.h = 0;
    3.16 -        mode.refresh_rate = 0;
    3.17 -
    3.18 -        if (SDL_SetDisplayMode(&mode) < 0) {
    3.19 -            fprintf(stderr, "Couldn't set display mode: %s\n",
    3.20 -                    SDL_GetError());
    3.21 -            quit(2);
    3.22 -        }
    3.23 +    /* Set the desktop mode, we don't care what it is */
    3.24 +    if (SDL_SetDisplayMode(NULL) < 0) {
    3.25 +        fprintf(stderr, "Couldn't set display mode: %s\n", SDL_GetError());
    3.26 +        quit(2);
    3.27      }
    3.28  
    3.29      /* Create the windows, initialize the renderers, and load the textures */