From 65d23f427036cad57475a5b657ee808442e69337 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 24 Jun 2006 17:01:29 +0000 Subject: [PATCH] Passing NULL to SDL_SetDisplayMode() will set the desktop mode. --- include/SDL_video.h | 2 +- src/video/SDL_video.c | 4 +--- test/testsprite2.c | 20 ++++---------------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/include/SDL_video.h b/include/SDL_video.h index d7f283616..3b203ba4b 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -458,7 +458,7 @@ extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const * * \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. */ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index b2fb80aa5..dab4043dc 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -534,10 +534,8 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode) return -1; } - /* Make sure there's an actual display mode to set */ if (!mode) { - SDL_SetError("No mode passed to SDL_SetDisplayMode"); - return -1; + mode = SDL_GetDesktopDisplayMode(); } display = &SDL_CurrentDisplay; display_mode = *mode; diff --git a/test/testsprite2.c b/test/testsprite2.c index 51f044a45..1dd457c9a 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -155,22 +155,10 @@ main(int argc, char *argv[]) } } - /* Initialize the video mode, if necessary */ - current_mode = SDL_GetCurrentDisplayMode(); - if (!current_mode->w || !current_mode->h) { - SDL_DisplayMode mode; - - /* 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); - } + /* Set the desktop mode, we don't care what it is */ + if (SDL_SetDisplayMode(NULL) < 0) { + fprintf(stderr, "Couldn't set display mode: %s\n", SDL_GetError()); + quit(2); } /* Create the windows, initialize the renderers, and load the textures */