From 30d4f29b4205075e8db57053beed2c607327b8c9 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 10 Apr 2019 01:01:15 +0000 Subject: [PATCH] SW, KenBuild: Populate the default resolution values from the current desktop settings git-svn-id: https://svn.eduke32.com/eduke32@7563 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/kenbuild/src/config.cpp | 29 +++++++++++++++++++++++++++++ source/sw/src/config.cpp | 29 ++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/source/kenbuild/src/config.cpp b/source/kenbuild/src/config.cpp index 1df08845f..31e23cf00 100644 --- a/source/kenbuild/src/config.cpp +++ b/source/kenbuild/src/config.cpp @@ -11,6 +11,33 @@ #endif #include "baselayer.h" +#if defined RENDERTYPESDL && defined SDL_TARGET && SDL_TARGET > 1 +# include "sdl_inc.h" +#endif + +static void Ken_SetDefaults() +{ +#if defined RENDERTYPESDL && 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) + { + xdimgame = xdim2d = dm.w; + ydimgame = ydim2d = dm.h; + } + else +#endif + { + xdimgame = xdim2d = 1024; + ydimgame = ydim2d = 768; + } +} + static int vesares[13][2] = {{320,200},{360,200},{320,240},{360,240},{320,400}, {360,400},{640,350},{640,400},{640,480},{800,600}, {1024,768},{1280,1024},{1600,1200}}; @@ -100,6 +127,8 @@ double msens; int Ken_loadsetup(const char *fn) { + Ken_SetDefaults(); + BFILE *fp; #define VL 32 char val[VL]; diff --git a/source/sw/src/config.cpp b/source/sw/src/config.cpp index f4c20b8ca..6d17bdddc 100644 --- a/source/sw/src/config.cpp +++ b/source/sw/src/config.cpp @@ -45,6 +45,10 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "_functio.h" #include "_config.h" +#if defined RENDERTYPESDL && defined SDL_TARGET && SDL_TARGET > 1 +# include "sdl_inc.h" +#endif + extern void ReadGameSetup(int32_t scripthandle); extern void WriteGameSetup(int32_t scripthandle); @@ -201,9 +205,28 @@ void CONFIG_SetDefaults(void) uint8_t k1,k2; ScreenMode = 1; - ScreenWidth = 640; - ScreenHeight = 480; - ScreenBPP = 8; + +#if defined RENDERTYPESDL && 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) + { + ScreenWidth = dm.w; + ScreenHeight = dm.h; + } + else +#endif + { + ScreenWidth = 1024; + ScreenHeight = 768; + } + + ScreenBPP = 32; FXDevice = 0; MusicDevice = 0; NumVoices = 32;