diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 536ad992d..12b6b1491 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -474,7 +474,11 @@ int main(int argc, char *argv[]) #elif defined(HAVE_GTK2) // Pre-initialize SDL video system in order to make sure XInitThreads() is called // before GTK starts talking to X11. - SDL_Init(SDL_INIT_VIDEO); + uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO); + if (inited == 0) + SDL_Init(SDL_INIT_VIDEO); + else if (!(inited & SDL_INIT_VIDEO)) + SDL_InitSubSystem(SDL_INIT_VIDEO); gtkbuild_init(&argc, &argv); #endif @@ -597,7 +601,14 @@ int32_t initsystem(void) if (sdlayer_checkversion()) return -1; - if (SDL_Init(sdlinitflags)) + int32_t err = 0; + uint32_t inited = SDL_WasInit(sdlinitflags); + if (inited == 0) + err = SDL_Init(sdlinitflags); + else if ((inited & sdlinitflags) != sdlinitflags) + err = SDL_InitSubSystem(sdlinitflags & ~inited); + + if (err) { initprintf("Initialization failed! (%s)\nNon-interactive mode enabled\n", SDL_GetError()); novideo = 1; diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index edf0ad6ec..638670d04 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -133,6 +133,10 @@ void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN]) } } +#if defined SDL_TARGET && SDL_TARGET > 1 +# include "sdl_inc.h" +#endif + void CONFIG_SetDefaults(void) { // JBF 20031211 @@ -152,11 +156,28 @@ void CONFIG_SetDefaults(void) ud.config.ScreenWidth = droidinfo.screen_width; ud.config.ScreenHeight = droidinfo.screen_height; #else - ud.config.ScreenWidth = 1024; - ud.config.ScreenHeight = 768; +# if defined SDL_MAJOR_VERSION && SDL_MAJOR_VERSION > 1 + uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO); + if (inited == 0) + SDL_Init(SDL_INIT_VIDEO); + else if (!(inited & SDL_INIT_VIDEO)) + SDL_InitSubSystem(SDL_INIT_VIDEO); + + SDL_DisplayMode dm; + if (SDL_GetDesktopDisplayMode(0, &dm) == 0) + { + ud.config.ScreenWidth = dm.w; + ud.config.ScreenHeight = dm.h; + } + else +# endif + { + ud.config.ScreenWidth = 1024; + ud.config.ScreenHeight = 768; + } #endif - ud.config.ScreenMode = 0; + ud.config.ScreenMode = 1; #ifdef USE_OPENGL ud.config.ScreenBPP = 32;