From f49a12791fc4a4b20a1c4a15784f2f2a4b62fcb9 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 23 Feb 2007 23:26:26 +0000 Subject: Add a configuration file value to allow the SDL video driver to be explicitly specified. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 838 --- src/i_video.c | 59 ++++++++++++++++++++++++++++++++++++++++------------------- src/i_video.h | 1 + src/m_misc.c | 1 + 3 files changed, 42 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 88370024..0e66154e 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -67,6 +67,10 @@ enum extern void M_QuitDOOM(); +// SDL video driver name + +char *video_driver = ""; + static SDL_Surface *screen; // palette @@ -1100,28 +1104,19 @@ static void CreateCursors(void) 1, 1, 0, 0); } -void I_InitGraphics(void) +static void SetSDLVideoDriver(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"); + // Allow a default value for the SDL video driver to be specified + // in the configuration file. - if (env != NULL) + if (strcmp(video_driver, "") != 0) { - char winenv[30]; - int winid; - - sscanf(env, "0x%x", &winid); - sprintf(winenv, "SDL_WINDOWID=%i", winid); + char *env_string; - 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 @@ void I_InitGraphics(void) { 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) { diff --git a/src/i_video.h b/src/i_video.h index e4e73041..a9d7faa1 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -60,6 +60,7 @@ void I_SetWindowIcon(void); void I_CheckIsScreensaver(void); +extern char *video_driver; extern int autoadjust_video_settings; extern boolean screenvisible; extern int screenmultiply; diff --git a/src/m_misc.c b/src/m_misc.c index 481539dc..9aaa0322 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -408,6 +408,7 @@ static default_t extra_defaults_list[] = {"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 -- cgit v1.2.3