Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Passing NULL to SDL_SetDisplayMode() will set the desktop mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 24, 2006
1 parent d0a8e40 commit 65d23f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/SDL_video.h
Expand Up @@ -458,7 +458,7 @@ extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const
* *
* \brief Set up the closest available mode on the current display. * \brief Set up the closest available mode on the current display.
* *
* \param mode The desired display mode * \param mode The desired display mode, or NULL to set the desktop mode.
* *
* \return 0 on success, or -1 if setting the display mode failed. * \return 0 on success, or -1 if setting the display mode failed.
*/ */
Expand Down
4 changes: 1 addition & 3 deletions src/video/SDL_video.c
Expand Up @@ -534,10 +534,8 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode)
return -1; return -1;
} }


/* Make sure there's an actual display mode to set */
if (!mode) { if (!mode) {
SDL_SetError("No mode passed to SDL_SetDisplayMode"); mode = SDL_GetDesktopDisplayMode();
return -1;
} }
display = &SDL_CurrentDisplay; display = &SDL_CurrentDisplay;
display_mode = *mode; display_mode = *mode;
Expand Down
20 changes: 4 additions & 16 deletions test/testsprite2.c
Expand Up @@ -155,22 +155,10 @@ main(int argc, char *argv[])
} }
} }


/* Initialize the video mode, if necessary */ /* Set the desktop mode, we don't care what it is */
current_mode = SDL_GetCurrentDisplayMode(); if (SDL_SetDisplayMode(NULL) < 0) {
if (!current_mode->w || !current_mode->h) { fprintf(stderr, "Couldn't set display mode: %s\n", SDL_GetError());
SDL_DisplayMode mode; quit(2);

/* Let the driver pick something it likes, we don't care */
mode.format = 0;
mode.w = 0;
mode.h = 0;
mode.refresh_rate = 0;

if (SDL_SetDisplayMode(&mode) < 0) {
fprintf(stderr, "Couldn't set display mode: %s\n",
SDL_GetError());
quit(2);
}
} }


/* Create the windows, initialize the renderers, and load the textures */ /* Create the windows, initialize the renderers, and load the textures */
Expand Down

0 comments on commit 65d23f4

Please sign in to comment.