libgoatvr
diff src/vr_openhmd.c @ 15:27fcd4c2969d
added VR_EYE_RES_SCALE option
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 25 Sep 2014 08:50:50 +0300 |
parents | b536bd21b37f |
children | b2d902fff68d |
line diff
1.1 --- a/src/vr_openhmd.c Thu Sep 25 07:52:49 2014 +0300 1.2 +++ b/src/vr_openhmd.c Thu Sep 25 08:50:50 2014 +0300 1.3 @@ -3,6 +3,7 @@ 1.4 #ifdef USE_OPENHMD 1.5 #include <stdio.h> 1.6 #include <stdlib.h> 1.7 +#include <string.h> 1.8 #include <openhmd/openhmd.h> 1.9 #include "opt.h" 1.10 1.11 @@ -60,14 +61,18 @@ 1.12 ipd /= 100.0f; /* convert ipd to meters */ 1.13 1.14 if((optdb = create_options())) { 1.15 + int eye_width, eye_height; 1.16 + 1.17 set_option_int(optdb, VR_DISPLAY_WIDTH, disp_width); 1.18 set_option_int(optdb, VR_DISPLAY_HEIGHT, disp_height); 1.19 set_option_float(optdb, VR_IPD, ipd); 1.20 1.21 - set_option_int(optdb, VR_LEYE_XRES, (int)(disp_width / 2.0 * FB_EMBIGGEN)); 1.22 - set_option_int(optdb, VR_LEYE_YRES, (int)(disp_height * FB_EMBIGGEN)); 1.23 - set_option_int(optdb, VR_REYE_XRES, (int)(disp_width / 2.0 * FB_EMBIGGEN)); 1.24 - set_option_int(optdb, VR_REYE_YRES, (int)(disp_height * FB_EMBIGGEN)); 1.25 + eye_width = (int)((float)(disp_width / 2) * FB_EMBIGGEN); 1.26 + eye_height = (int)((float)disp_height * FB_EMBIGGEN); 1.27 + set_option_int(optdb, VR_LEYE_XRES, eye_width); 1.28 + set_option_int(optdb, VR_LEYE_YRES, eye_height); 1.29 + set_option_int(optdb, VR_REYE_XRES, eye_width); 1.30 + set_option_int(optdb, VR_REYE_YRES, eye_height); 1.31 } 1.32 1.33 ohmd_device_getf(dev, OHMD_DISTORTION_K, distort_k); 1.34 @@ -91,15 +96,30 @@ 1.35 1.36 static int set_option(const char *opt, enum opt_type type, void *valp) 1.37 { 1.38 + float fval; 1.39 + 1.40 switch(type) { 1.41 case OTYPE_INT: 1.42 + fval = (float)*(int*)valp; 1.43 set_option_int(optdb, opt, *(int*)valp); 1.44 break; 1.45 1.46 case OTYPE_FLOAT: 1.47 - set_option_float(optdb, opt, *(float*)valp); 1.48 + fval = *(float*)valp; 1.49 + set_option_float(optdb, opt, fval); 1.50 break; 1.51 } 1.52 + 1.53 + if(strcmp(opt, VR_EYE_RES_SCALE) == 0) { 1.54 + int eye_width, eye_height; 1.55 + eye_width = (int)((float)(disp_width / 2) * FB_EMBIGGEN * fval); 1.56 + eye_height = (int)((float)disp_height * FB_EMBIGGEN * fval); 1.57 + set_option_int(optdb, VR_LEYE_XRES, eye_width); 1.58 + set_option_int(optdb, VR_LEYE_YRES, eye_height); 1.59 + set_option_int(optdb, VR_REYE_XRES, eye_width); 1.60 + set_option_int(optdb, VR_REYE_YRES, eye_height); 1.61 + } 1.62 + 1.63 return 0; 1.64 } 1.65