libgoatvr

diff src/vr.c @ 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
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  }