ref: f49a12791fc4a4b20a1c4a15784f2f2a4b62fcb9
parent: e6d0591bd0674b0c56da7ca92a3721fa48aa1464
author: Simon Howard <[email protected]>
date: Fri Feb 23 18:26:26 EST 2007
Add a configuration file value to allow the SDL video driver to be explicitly specified. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 838
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -67,6 +67,10 @@
extern void M_QuitDOOM();
+// SDL video driver name
+
+char *video_driver = "";
+
static SDL_Surface *screen;
// palette
@@ -1100,28 +1104,19 @@
1, 1, 0, 0);
}
-void I_InitGraphics(void)
+static void SetSDLVideoDriver(void)
{
- SDL_Event dummy;
- byte *doompal;
- int flags = 0;
- char *env;
+ // Allow a default value for the SDL video driver to be specified
+ // in the configuration file.
- // Pass through the XSCREENSAVER_WINDOW environment variable to
- // SDL_WINDOWID, to embed the SDL window into the Xscreensaver
- // window.
-
- env = getenv("XSCREENSAVER_WINDOW");
-
- if (env != NULL)
+ if (strcmp(video_driver, "") != 0)
{
- char winenv[30];
- int winid;
+ char *env_string;
- sscanf(env, "0x%x", &winid);
- sprintf(winenv, "SDL_WINDOWID=%i", winid);
-
- putenv(winenv);
+ env_string = malloc(strlen(video_driver) + 30);
+ sprintf(env_string, "SDL_VIDEODRIVER=%s", env_string);
+ putenv(env_string);
+ free(env_string);
}
#ifdef _WIN32
@@ -1152,8 +1147,34 @@
{
putenv("SDL_VIDEODRIVER=directx");
}
-
#endif
+}
+
+void I_InitGraphics(void)
+{
+ SDL_Event dummy;
+ byte *doompal;
+ int flags = 0;
+ char *env;
+
+ // Pass through the XSCREENSAVER_WINDOW environment variable to
+ // SDL_WINDOWID, to embed the SDL window into the Xscreensaver
+ // window.
+
+ env = getenv("XSCREENSAVER_WINDOW");
+
+ if (env != NULL)
+ {
+ char winenv[30];
+ int winid;
+
+ sscanf(env, "0x%x", &winid);
+ sprintf(winenv, "SDL_WINDOWID=%i", winid);
+
+ putenv(winenv);
+ }
+
+ SetSDLVideoDriver();
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -60,6 +60,7 @@
void I_CheckIsScreensaver(void);
+extern char *video_driver;
extern int autoadjust_video_settings;
extern boolean screenvisible;
extern int screenmultiply;
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -408,6 +408,7 @@
{"show_endoom", &show_endoom, DEFAULT_INT, 0, 0},
{"vanilla_savegame_limit", &vanilla_savegame_limit, DEFAULT_INT, 0, 0},
{"vanilla_demo_limit", &vanilla_demo_limit, DEFAULT_INT, 0, 0},
+ {"video_driver", &video_driver, DEFAULT_STRING, 0, 0},
#ifdef FEATURE_MULTIPLAYER
{"player_name", &net_player_name, DEFAULT_STRING, 0, 0},
#endif