# HG changeset patch # User John Tsiombikas # Date 1411624250 -10800 # Node ID 27fcd4c2969deeda7856c1ed86ff85eed7e15f5c # Parent 604a9a0a8c372cfe832fc22e7bed70437325f26a added VR_EYE_RES_SCALE option diff -r 604a9a0a8c37 -r 27fcd4c2969d src/vr.c --- a/src/vr.c Thu Sep 25 07:52:49 2014 +0300 +++ b/src/vr.c Thu Sep 25 08:50:50 2014 +0300 @@ -36,6 +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_EYE_HEIGHT, 1.675); set_option_float(defopt, VR_IPD, 0.064); } diff -r 604a9a0a8c37 -r 27fcd4c2969d src/vr.h --- a/src/vr.h Thu Sep 25 07:52:49 2014 +0300 +++ b/src/vr.h Thu Sep 25 08:50:50 2014 +0300 @@ -10,6 +10,7 @@ #define VR_REYE_YRES "right-eye-yres" #define VR_WIN_XOFFS "win-xoffset" #define VR_WIN_YOFFS "win-yoffset" +#define VR_EYE_RES_SCALE "eye-res-scale" /* default 1 */ /* unit: meters */ #define VR_EYE_HEIGHT "eye-height" #define VR_IPD "ipd" diff -r 604a9a0a8c37 -r 27fcd4c2969d src/vr_libovr.c --- a/src/vr_libovr.c Thu Sep 25 07:52:49 2014 +0300 +++ b/src/vr_libovr.c Thu Sep 25 08:50:50 2014 +0300 @@ -91,6 +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_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); @@ -152,15 +153,30 @@ static int set_option(const char *opt, enum opt_type type, void *valp) { + float fval; + switch(type) { case OTYPE_INT: + fval = (float)*(int*)valp; set_option_int(optdb, opt, *(int*)valp); break; case OTYPE_FLOAT: - set_option_float(optdb, opt, *(float*)valp); + fval = *(float*)valp; + set_option_float(optdb, opt, fval); break; } + + if(hmd && strcmp(opt, VR_EYE_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); + + set_option_int(optdb, VR_LEYE_XRES, eye_res[0].w); + 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); + } + return 0; } diff -r 604a9a0a8c37 -r 27fcd4c2969d src/vr_openhmd.c --- a/src/vr_openhmd.c Thu Sep 25 07:52:49 2014 +0300 +++ b/src/vr_openhmd.c Thu Sep 25 08:50:50 2014 +0300 @@ -3,6 +3,7 @@ #ifdef USE_OPENHMD #include #include +#include #include #include "opt.h" @@ -60,14 +61,18 @@ ipd /= 100.0f; /* convert ipd to meters */ if((optdb = create_options())) { + int eye_width, eye_height; + set_option_int(optdb, VR_DISPLAY_WIDTH, disp_width); set_option_int(optdb, VR_DISPLAY_HEIGHT, disp_height); set_option_float(optdb, VR_IPD, ipd); - set_option_int(optdb, VR_LEYE_XRES, (int)(disp_width / 2.0 * FB_EMBIGGEN)); - set_option_int(optdb, VR_LEYE_YRES, (int)(disp_height * FB_EMBIGGEN)); - set_option_int(optdb, VR_REYE_XRES, (int)(disp_width / 2.0 * FB_EMBIGGEN)); - set_option_int(optdb, VR_REYE_YRES, (int)(disp_height * FB_EMBIGGEN)); + eye_width = (int)((float)(disp_width / 2) * FB_EMBIGGEN); + eye_height = (int)((float)disp_height * FB_EMBIGGEN); + set_option_int(optdb, VR_LEYE_XRES, eye_width); + set_option_int(optdb, VR_LEYE_YRES, eye_height); + set_option_int(optdb, VR_REYE_XRES, eye_width); + set_option_int(optdb, VR_REYE_YRES, eye_height); } ohmd_device_getf(dev, OHMD_DISTORTION_K, distort_k); @@ -91,15 +96,30 @@ static int set_option(const char *opt, enum opt_type type, void *valp) { + float fval; + switch(type) { case OTYPE_INT: + fval = (float)*(int*)valp; set_option_int(optdb, opt, *(int*)valp); break; case OTYPE_FLOAT: - set_option_float(optdb, opt, *(float*)valp); + fval = *(float*)valp; + set_option_float(optdb, opt, fval); break; } + + if(strcmp(opt, VR_EYE_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); + set_option_int(optdb, VR_LEYE_XRES, eye_width); + set_option_int(optdb, VR_LEYE_YRES, eye_height); + set_option_int(optdb, VR_REYE_XRES, eye_width); + set_option_int(optdb, VR_REYE_YRES, eye_height); + } + return 0; }