ref: 288d322c0b679675a80c0fc763b1063613c77ce5
parent: cf82ce9d7bb8d71ae583753aab642c5ba4ee8d06
author: Simon Howard <[email protected]>
date: Wed Nov 24 17:43:37 EST 2010
Add configuration file parameter and command line option to specify the screen pixel depth. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2166
--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -265,6 +265,7 @@
{"startup_delay", &startup_delay, DEFAULT_INT, 0, 0},
{"screen_width", &screen_width, DEFAULT_INT, 0, 0},
{"screen_height", &screen_height, DEFAULT_INT, 0, 0},
+ {"screen_bpp", &screen_bpp, DEFAULT_INT, 0, 0},
{"grabmouse", &grabmouse, DEFAULT_INT, 0, 0},
{"novert", &novert, DEFAULT_INT, 0, 0},
{"mouse_acceleration", &mouse_acceleration, DEFAULT_FLOAT, 0, 0},
--- a/setup/display.c
+++ b/setup/display.c
@@ -75,6 +75,7 @@
int fullscreen = 1;
int screen_width = 320;
int screen_height = 200;
+int screen_bpp = 8;
int startup_delay = 1000;
int show_endoom = 1;
--- a/setup/display.h
+++ b/setup/display.h
@@ -26,6 +26,7 @@
extern int aspect_ratio_correct;
extern int fullscreen;
extern int screen_width, screen_height;
+extern int screen_bpp;
extern int startup_delay;
extern int show_endoom;
extern char *video_driver;
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -126,6 +126,10 @@
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.
@@ -1407,6 +1411,33 @@
//!
// @category video
+ // @arg <bpp>
+ //
+ // 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 <WxY>
//
// Specify the screen mode (when running fullscreen) or the window
@@ -1558,7 +1589,6 @@
{
byte *doompal;
int flags = 0;
- int bpp = 8;
doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE);
@@ -1573,12 +1603,8 @@
flags |= SDL_SWSURFACE;
- if (M_CheckParm("-8in32"))
+ if (screen_bpp == 8)
{
- bpp = 32;
- }
- else
- {
flags |= SDL_HWPALETTE | SDL_DOUBLEBUF;
}
@@ -1591,12 +1617,12 @@
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)
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -89,6 +89,7 @@
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;
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -616,6 +616,12 @@
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.
// When running full screen, this has no effect.