From db6225eb5d0e329447f12f6bf8d7b07abfd37518 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 9 Apr 2012 19:22:00 +0000 Subject: [PATCH] On Windows, auto-determine r_screenaspect on startup. Consequently, it's not saved as a setting in either the game or editor config files. We do this by calling "GetSystemMetrics(SM_CXSCREEN)" (accordingly for y) and calculating the cvar by dividing common factors, since it has to be in the form WWHH. This may fail for _really_ strange screen dimensions, so a log message is printed at the very beginning. git-svn-id: https://svn.eduke32.com/eduke32@2601 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/baselayer.c | 11 +++++-- polymer/eduke32/build/src/config.c | 11 +++++-- polymer/eduke32/build/src/winlayer.c | 41 +++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index 11dc88be6..bab97e02b 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -297,11 +297,18 @@ static int32_t osdcmd_cvar_set_baselayer(const osdfuncparm_t *parm) int32_t baselayer_init(void) { uint32_t i; - +#ifdef _WIN32 +// on Windows, don't save the "r_screenaspect" cvar because the physical screen size is +// determined at startup +# define SCREENASPECT_CVAR_TYPE (CVAR_UINT|CVAR_NOSAVE) +#else +# define SCREENASPECT_CVAR_TYPE (CVAR_UINT) +#endif cvar_t cvars_engine[] = { { "r_usenewaspect","r_usenewaspect: enable/disable new screen aspect ratio determination code",(void *) &r_usenewaspect, CVAR_BOOL, 0, 1 }, - { "r_screenaspect","r_screenaspect: if using the new aspect code and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",(void *) &r_screenxy, CVAR_UINT, 100, 9999 }, + { "r_screenaspect","r_screenaspect: if using the new aspect code and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9", + (void *) &r_screenxy, SCREENASPECT_CVAR_TYPE, 100, 9999 }, { "r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",(void *) &novoxmips, CVAR_BOOL, 0, 1 }, { "r_voxels","r_voxels: enable/disable automatic sprite->voxel rendering",(void *) &usevoxels, CVAR_BOOL, 0, 1 }, #ifdef YAX_ENABLE diff --git a/polymer/eduke32/build/src/config.c b/polymer/eduke32/build/src/config.c index c231f64ec..5fd62a662 100644 --- a/polymer/eduke32/build/src/config.c +++ b/polymer/eduke32/build/src/config.c @@ -201,13 +201,14 @@ int32_t loadsetup(const char *fn) #endif if (readconfig(fp, "r_usenewaspect", val, VL) > 0) r_usenewaspect = !!atoi_safe(val); +#ifndef RENDERTYPEWIN if (readconfig(fp, "r_screenxy", val, VL) > 0) { r_screenxy = clamp(atoi_safe(val), 0, 9999); if (r_screenxy/100==0 || r_screenxy%100==0) r_screenxy = 403; } - +#endif if (readconfig(fp, "gameexecutable", val, VL) > 0) Bstrcpy(game_executable, val); @@ -399,8 +400,10 @@ int32_t writesetup(const char *fn) #endif "; Use new aspect determination code? (classic/Polymost)\n" "r_usenewaspect = %d\n" +#ifndef RENDERTYPEWIN "; Screen aspect for fullscreen, in the form WWHH (e.g. 1609 for 16:9)\n" "r_screenxy = %d\n" +#endif "\n" #ifdef RENDERTYPEWIN @@ -569,8 +572,10 @@ int32_t writesetup(const char *fn) glusetexcache, glusememcache, gltexfiltermode, glanisotropy,r_downsize,glusetexcompr, shadescale, #endif - r_usenewaspect, r_screenxy, -#ifdef RENDERTYPEWIN + r_usenewaspect, +#ifndef RENDERTYPEWIN + r_screenxy, +#else maxrefreshfreq, windowpos, windowx, windowy, #endif vid_gamma_3d>=0?vid_gamma_3d:vid_gamma, diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index c2d6a3199..a1be5ab9f 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -28,6 +28,7 @@ #include "compat.h" #include "winlayer.h" +#include "baselayer.h" #include "pragmas.h" #include "build.h" #include "a.h" @@ -299,6 +300,31 @@ static void SignalHandler(int32_t signum) } } +static void divcommon(int32_t *ap, int32_t *bp) +{ + const int32_t p[] = {2,3,5,7,11,13,17,19}; + const int32_t N = (int32_t)(sizeof(p)/sizeof(p[0])); + int32_t a=*ap, b=*bp; + + while (1) + { + int32_t i; + + for (i=0; i= 1 && screenx <= 99 && screeny >= 1 && screeny <= 99) + r_screenxy = screenx*100 + screeny, good=1; + + initprintf("Automatic fullscreen size determination: %d %d -> %d %d%s.\n", + oscreenx, oscreeny, screenx, screeny, good?"":" (failed)"); + } + r = app_main(_buildargc, _buildargv); fclose(stdout);