From 288d322c0b679675a80c0fc763b1063613c77ce5 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 24 Nov 2010 22:43:37 +0000 Subject: Add configuration file parameter and command line option to specify the screen pixel depth. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2166 --- src/i_video.c | 42 ++++++++++++++++++++++++++++++++++-------- src/i_video.h | 1 + src/m_config.c | 6 ++++++ 3 files changed, 41 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 1139157d..577b7415 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -126,6 +126,10 @@ static boolean native_surface; int screen_width = SCREENWIDTH; int screen_height = SCREENHEIGHT; +// Color depth. + +int screen_bpp = 8; + // Automatically adjust video settings if the selected mode is // not a valid video mode. @@ -1405,6 +1409,33 @@ static void CheckCommandLine(void) screen_height = atoi(myargv[i + 1]); } + //! + // @category video + // @arg + // + // Specify the color depth of the screen, in bits per pixel. + // + + i = M_CheckParm("-bpp"); + + if (i > 0) + { + screen_bpp = atoi(myargv[i + 1]); + } + + // Because we love Eternity: + + //! + // @category video + // + // Set the color depth of the screen to 32 bits per pixel. + // + + if (M_CheckParm("-8in32")) + { + screen_bpp = 32; + } + //! // @category video // @arg @@ -1558,7 +1589,6 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h) { byte *doompal; int flags = 0; - int bpp = 8; doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE); @@ -1573,11 +1603,7 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h) flags |= SDL_SWSURFACE; - if (M_CheckParm("-8in32")) - { - bpp = 32; - } - else + if (screen_bpp == 8) { flags |= SDL_HWPALETTE | SDL_DOUBLEBUF; } @@ -1591,12 +1617,12 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h) flags |= SDL_RESIZABLE; } - screen = SDL_SetVideoMode(w, h, bpp, flags); + screen = SDL_SetVideoMode(w, h, screen_bpp, flags); if (screen == NULL) { I_Error("Error setting video mode %ix%ix%ibpp: %s\n", - w, h, bpp, SDL_GetError()); + w, h, screen_bpp, SDL_GetError()); } if (screen->format->BitsPerPixel == 8) diff --git a/src/i_video.h b/src/i_video.h index 94ffcc29..44fe1cd2 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -89,6 +89,7 @@ extern char *video_driver; extern int autoadjust_video_settings; extern boolean screenvisible; extern int screen_width, screen_height; +extern int screen_bpp; extern int fullscreen; extern int aspect_ratio_correct; extern int grabmouse; diff --git a/src/m_config.c b/src/m_config.c index 2065700e..a4cacd95 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -615,6 +615,12 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_INT(screen_height, screen_height), + //! + // Color depth of the screen, in bits. + // + + CONFIG_VARIABLE_INT(screen_bpp, screen_bpp), + //! // If this is non-zero, the mouse will be "grabbed" when running // in windowed mode so that it can be used as an input device. -- cgit v1.2.3