# HG changeset patch # User John Tsiombikas # Date 1411625217 -10800 # Node ID b2d902fff68d47559ae86ac22074572cb06676af # Parent 27fcd4c2969deeda7856c1ed86ff85eed7e15f5c renamed VR_EYE_RES_SCALE to VR_RENDER_RES_SCALE added convenience options: VR_RENDER_XRES & VR_RENDER_YRES, which are derived from VR_LEYE_XRES, VR_REYE_XRES, etc. diff -r 27fcd4c2969d -r b2d902fff68d src/vr.c --- a/src/vr.c Thu Sep 25 08:50:50 2014 +0300 +++ b/src/vr.c Thu Sep 25 09:06:57 2014 +0300 @@ -36,7 +36,7 @@ /* create the default options database */ if(!defopt && (defopt = create_options())) { - set_option_float(defopt, VR_EYE_RES_SCALE, 1.0); + set_option_float(defopt, VR_RENDER_RES_SCALE, 1.0); set_option_float(defopt, VR_EYE_HEIGHT, 1.675); set_option_float(defopt, VR_IPD, 0.064); } @@ -134,12 +134,45 @@ } } +static int def_option_int(const char *optname) +{ + int res = 0; + int left, right; + + if(strcmp(optname, VR_RENDER_XRES) == 0) { + if(vrm && vrm->get_option && vrm->get_option(optname, OTYPE_INT, &left) != -1 && + vrm->get_option(optname, OTYPE_INT, &right) != -1) { + return left + right; + } + } else if(strcmp(optname, VR_RENDER_YRES) == 0) { + if(vrm && vrm->get_option && vrm->get_option(optname, OTYPE_INT, &left) != -1 && + vrm->get_option(optname, OTYPE_INT, &right) != -1) { + return left > right ? left : right; + } + } + + get_option_int(defopt, optname, &res); + return res; +} + +static float def_option_float(const char *optname) +{ + int res = 0; + + if(strcmp(optname, VR_RENDER_XRES) == 0 || strcmp(optname, VR_RENDER_YRES) == 0) { + return (float)def_option_int(optname); + } + + get_option_float(defopt, optname, &res); + return res; +} + int vr_geti(const char *optname) { int res = 0; if(!vrm || !vrm->get_option || vrm->get_option(optname, OTYPE_INT, &res) == -1) { - get_option_int(defopt, optname, &res); /* fallback */ + res = def_option_int(optname); } return res; } @@ -149,7 +182,7 @@ float res = 0.0f; if(!vrm || !vrm->get_option || vrm->get_option(optname, OTYPE_FLOAT, &res) == -1) { - get_option_float(defopt, optname, &res); /* fallback */ + res = def_option_float(optname); } return res; } diff -r 27fcd4c2969d -r b2d902fff68d src/vr.h --- a/src/vr.h Thu Sep 25 08:50:50 2014 +0300 +++ b/src/vr.h Thu Sep 25 09:06:57 2014 +0300 @@ -8,9 +8,11 @@ #define VR_LEYE_YRES "left-eye-yres" #define VR_REYE_XRES "right-eye-xres" #define VR_REYE_YRES "right-eye-yres" +#define VR_RENDER_XRES "render-xres" /* VR_LEYE_XRES + VR_REYE_XRES */ +#define VR_RENDER_YRES "render-yres" /* max(VR_LEYE_YRES, VR_REYE_YRES) */ #define VR_WIN_XOFFS "win-xoffset" #define VR_WIN_YOFFS "win-yoffset" -#define VR_EYE_RES_SCALE "eye-res-scale" /* default 1 */ +#define VR_RENDER_RES_SCALE "render-res-scale" /* default 1 */ /* unit: meters */ #define VR_EYE_HEIGHT "eye-height" #define VR_IPD "ipd" diff -r 27fcd4c2969d -r b2d902fff68d src/vr_libovr.c --- a/src/vr_libovr.c Thu Sep 25 08:50:50 2014 +0300 +++ b/src/vr_libovr.c Thu Sep 25 09:06:57 2014 +0300 @@ -91,7 +91,7 @@ set_option_int(optdb, VR_LEYE_YRES, eye_res[0].h); set_option_int(optdb, VR_REYE_XRES, eye_res[1].w); set_option_int(optdb, VR_REYE_YRES, eye_res[1].h); - set_option_float(optdb, VR_EYE_RES_SCALE, 1.0); + set_option_float(optdb, VR_RENDER_RES_SCALE, 1.0); set_option_float(optdb, VR_EYE_HEIGHT, ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, OVR_DEFAULT_EYE_HEIGHT)); set_option_float(optdb, VR_IPD, ovrHmd_GetFloat(hmd, OVR_KEY_IPD, OVR_DEFAULT_IPD)); set_option_int(optdb, VR_WIN_XOFFS, hmd->WindowsPos.x); @@ -167,7 +167,7 @@ break; } - if(hmd && strcmp(opt, VR_EYE_RES_SCALE) == 0) { + if(hmd && strcmp(opt, VR_RENDER_RES_SCALE) == 0) { eye_res[0] = ovrHmd_GetFovTextureSize(hmd, ovrEye_Left, eye_fov[0], fval); eye_res[1] = ovrHmd_GetFovTextureSize(hmd, ovrEye_Right, eye_fov[1], fval); diff -r 27fcd4c2969d -r b2d902fff68d src/vr_openhmd.c --- a/src/vr_openhmd.c Thu Sep 25 08:50:50 2014 +0300 +++ b/src/vr_openhmd.c Thu Sep 25 09:06:57 2014 +0300 @@ -110,7 +110,7 @@ break; } - if(strcmp(opt, VR_EYE_RES_SCALE) == 0) { + if(strcmp(opt, VR_RENDER_RES_SCALE) == 0) { int eye_width, eye_height; eye_width = (int)((float)(disp_width / 2) * FB_EMBIGGEN * fval); eye_height = (int)((float)disp_height * FB_EMBIGGEN * fval);