libgoatvr
changeset 16:b2d902fff68d
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.
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 25 Sep 2014 09:06:57 +0300 |
parents | 27fcd4c2969d |
children | 3de7339841d0 |
files | src/vr.c src/vr.h src/vr_libovr.c src/vr_openhmd.c |
diffstat | 4 files changed, 42 insertions(+), 7 deletions(-) [+] |
line diff
1.1 --- a/src/vr.c Thu Sep 25 08:50:50 2014 +0300 1.2 +++ b/src/vr.c Thu Sep 25 09:06:57 2014 +0300 1.3 @@ -36,7 +36,7 @@ 1.4 1.5 /* create the default options database */ 1.6 if(!defopt && (defopt = create_options())) { 1.7 - set_option_float(defopt, VR_EYE_RES_SCALE, 1.0); 1.8 + set_option_float(defopt, VR_RENDER_RES_SCALE, 1.0); 1.9 set_option_float(defopt, VR_EYE_HEIGHT, 1.675); 1.10 set_option_float(defopt, VR_IPD, 0.064); 1.11 } 1.12 @@ -134,12 +134,45 @@ 1.13 } 1.14 } 1.15 1.16 +static int def_option_int(const char *optname) 1.17 +{ 1.18 + int res = 0; 1.19 + int left, right; 1.20 + 1.21 + if(strcmp(optname, VR_RENDER_XRES) == 0) { 1.22 + if(vrm && vrm->get_option && vrm->get_option(optname, OTYPE_INT, &left) != -1 && 1.23 + vrm->get_option(optname, OTYPE_INT, &right) != -1) { 1.24 + return left + right; 1.25 + } 1.26 + } else if(strcmp(optname, VR_RENDER_YRES) == 0) { 1.27 + if(vrm && vrm->get_option && vrm->get_option(optname, OTYPE_INT, &left) != -1 && 1.28 + vrm->get_option(optname, OTYPE_INT, &right) != -1) { 1.29 + return left > right ? left : right; 1.30 + } 1.31 + } 1.32 + 1.33 + get_option_int(defopt, optname, &res); 1.34 + return res; 1.35 +} 1.36 + 1.37 +static float def_option_float(const char *optname) 1.38 +{ 1.39 + int res = 0; 1.40 + 1.41 + if(strcmp(optname, VR_RENDER_XRES) == 0 || strcmp(optname, VR_RENDER_YRES) == 0) { 1.42 + return (float)def_option_int(optname); 1.43 + } 1.44 + 1.45 + get_option_float(defopt, optname, &res); 1.46 + return res; 1.47 +} 1.48 + 1.49 int vr_geti(const char *optname) 1.50 { 1.51 int res = 0; 1.52 1.53 if(!vrm || !vrm->get_option || vrm->get_option(optname, OTYPE_INT, &res) == -1) { 1.54 - get_option_int(defopt, optname, &res); /* fallback */ 1.55 + res = def_option_int(optname); 1.56 } 1.57 return res; 1.58 } 1.59 @@ -149,7 +182,7 @@ 1.60 float res = 0.0f; 1.61 1.62 if(!vrm || !vrm->get_option || vrm->get_option(optname, OTYPE_FLOAT, &res) == -1) { 1.63 - get_option_float(defopt, optname, &res); /* fallback */ 1.64 + res = def_option_float(optname); 1.65 } 1.66 return res; 1.67 }
2.1 --- a/src/vr.h Thu Sep 25 08:50:50 2014 +0300 2.2 +++ b/src/vr.h Thu Sep 25 09:06:57 2014 +0300 2.3 @@ -8,9 +8,11 @@ 2.4 #define VR_LEYE_YRES "left-eye-yres" 2.5 #define VR_REYE_XRES "right-eye-xres" 2.6 #define VR_REYE_YRES "right-eye-yres" 2.7 +#define VR_RENDER_XRES "render-xres" /* VR_LEYE_XRES + VR_REYE_XRES */ 2.8 +#define VR_RENDER_YRES "render-yres" /* max(VR_LEYE_YRES, VR_REYE_YRES) */ 2.9 #define VR_WIN_XOFFS "win-xoffset" 2.10 #define VR_WIN_YOFFS "win-yoffset" 2.11 -#define VR_EYE_RES_SCALE "eye-res-scale" /* default 1 */ 2.12 +#define VR_RENDER_RES_SCALE "render-res-scale" /* default 1 */ 2.13 /* unit: meters */ 2.14 #define VR_EYE_HEIGHT "eye-height" 2.15 #define VR_IPD "ipd"
3.1 --- a/src/vr_libovr.c Thu Sep 25 08:50:50 2014 +0300 3.2 +++ b/src/vr_libovr.c Thu Sep 25 09:06:57 2014 +0300 3.3 @@ -91,7 +91,7 @@ 3.4 set_option_int(optdb, VR_LEYE_YRES, eye_res[0].h); 3.5 set_option_int(optdb, VR_REYE_XRES, eye_res[1].w); 3.6 set_option_int(optdb, VR_REYE_YRES, eye_res[1].h); 3.7 - set_option_float(optdb, VR_EYE_RES_SCALE, 1.0); 3.8 + set_option_float(optdb, VR_RENDER_RES_SCALE, 1.0); 3.9 set_option_float(optdb, VR_EYE_HEIGHT, ovrHmd_GetFloat(hmd, OVR_KEY_EYE_HEIGHT, OVR_DEFAULT_EYE_HEIGHT)); 3.10 set_option_float(optdb, VR_IPD, ovrHmd_GetFloat(hmd, OVR_KEY_IPD, OVR_DEFAULT_IPD)); 3.11 set_option_int(optdb, VR_WIN_XOFFS, hmd->WindowsPos.x); 3.12 @@ -167,7 +167,7 @@ 3.13 break; 3.14 } 3.15 3.16 - if(hmd && strcmp(opt, VR_EYE_RES_SCALE) == 0) { 3.17 + if(hmd && strcmp(opt, VR_RENDER_RES_SCALE) == 0) { 3.18 eye_res[0] = ovrHmd_GetFovTextureSize(hmd, ovrEye_Left, eye_fov[0], fval); 3.19 eye_res[1] = ovrHmd_GetFovTextureSize(hmd, ovrEye_Right, eye_fov[1], fval); 3.20
4.1 --- a/src/vr_openhmd.c Thu Sep 25 08:50:50 2014 +0300 4.2 +++ b/src/vr_openhmd.c Thu Sep 25 09:06:57 2014 +0300 4.3 @@ -110,7 +110,7 @@ 4.4 break; 4.5 } 4.6 4.7 - if(strcmp(opt, VR_EYE_RES_SCALE) == 0) { 4.8 + if(strcmp(opt, VR_RENDER_RES_SCALE) == 0) { 4.9 int eye_width, eye_height; 4.10 eye_width = (int)((float)(disp_width / 2) * FB_EMBIGGEN * fval); 4.11 eye_height = (int)((float)disp_height * FB_EMBIGGEN * fval);