libgoatvr
changeset 7:6896f9cf9621
- configure now emits config.status with the current confure invocation
- now vr_init will heed the VR_MODULE env var for the name of the module to use
- more stuff on the openhmd module
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 19 Sep 2014 15:16:51 +0300 |
parents | b71314e80654 |
children | 3d9ec6fe97d7 |
files | Makefile.in configure example/Makefile src/vr.c src/vr_libovr.c src/vr_openhmd.c |
diffstat | 6 files changed, 43 insertions(+), 25 deletions(-) [+] |
line diff
1.1 --- a/Makefile.in Fri Sep 19 05:30:20 2014 +0300 1.2 +++ b/Makefile.in Fri Sep 19 15:16:51 2014 +0300 1.3 @@ -11,7 +11,7 @@ 1.4 endif 1.5 ifdef use_openhmd 1.6 mod_cflags += -DUSE_OPENHMD 1.7 - mod_libs += -lhmd 1.8 + mod_libs += -lopenhmd 1.9 endif 1.10 1.11 CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic) $(mod_cflags) 1.12 @@ -30,11 +30,17 @@ 1.13 endif 1.14 1.15 .PHONY: all 1.16 -all: $(lib_so) $(lib_a) 1.17 +all: $(lib_so) $(lib_a) $(soname) $(ldname) 1.18 1.19 $(lib_so): $(obj) 1.20 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS) 1.21 1.22 +$(soname): $(lib_so) 1.23 + ln -sf $< $@ 1.24 + 1.25 +$(ldname): $(soname) 1.26 + ln -sf $< $@ 1.27 + 1.28 $(lib_a): $(obj) 1.29 $(AR) rcs $@ $(obj) 1.30 1.31 @@ -45,7 +51,7 @@ 1.32 1.33 .PHONY: clean 1.34 clean: 1.35 - rm -f $(obj) $(bin) 1.36 + rm -f $(obj) $(lib_so) $(lib_a) $(soname) $(ldname) 1.37 1.38 .PHONY: cleandep 1.39 cleandep: clean
2.1 --- a/configure Fri Sep 19 05:30:20 2014 +0300 2.2 +++ b/configure Fri Sep 19 15:16:51 2014 +0300 2.3 @@ -6,7 +6,11 @@ 2.4 use_libovr=true 2.5 use_openhmd=false # not done 2.6 2.7 +echo "$0 \\" >config.status 2.8 +chmod +x config.status 2.9 + 2.10 while [ $# != 0 ]; do 2.11 + echo "$1 \\" >>config.status 2.12 case $1 in 2.13 --prefix=*) 2.14 value=`echo $arg | sed 's/--prefix=//'` 2.15 @@ -57,6 +61,8 @@ 2.16 shift 2.17 done 2.18 2.19 +echo >>config.status 2.20 + 2.21 echo 'Configuring libgoatvr...' 2.22 echo " install prefix: $prefix" 2.23 echo ' optimizations: ' `$opt && echo yes || echo no`
3.1 --- a/example/Makefile Fri Sep 19 05:30:20 2014 +0300 3.2 +++ b/example/Makefile Fri Sep 19 15:16:51 2014 +0300 3.3 @@ -3,10 +3,10 @@ 3.4 bin = test 3.5 3.6 vrlib_root = .. 3.7 -vrlib = $(vrlib_root)/libgoatvr.a 3.8 +vrlib = $(vrlib_root)/libgoatvr.so 3.9 3.10 CFLAGS = -pedantic -Wall -g `pkg-config --cflags sdl2` -I$(vrlib_root)/src 3.11 -LDFLAGS = $(libgl) `pkg-config --libs sdl2` $(vrlib) 3.12 +LDFLAGS = $(libgl) `pkg-config --libs sdl2` -L$(vrlib_root) -lgoatvr -Wl,-rpath=$(vrlib_root) 3.13 3.14 ifeq ($(shell uname -s), Darwin) 3.15 libgl = -framework OpenGL -lGLEW
4.1 --- a/src/vr.c Fri Sep 19 05:30:20 2014 +0300 4.2 +++ b/src/vr.c Fri Sep 19 15:16:51 2014 +0300 4.3 @@ -1,4 +1,5 @@ 4.4 #include <stdio.h> 4.5 +#include <stdlib.h> 4.6 #include <string.h> 4.7 #include "opengl.h" 4.8 #include "vr.h" 4.9 @@ -31,6 +32,7 @@ 4.10 int vr_init(void) 4.11 { 4.12 int i, nmodules; 4.13 + char *vrmod_env; 4.14 4.15 /* create the default options database */ 4.16 if(!defopt && (defopt = create_options())) { 4.17 @@ -50,15 +52,18 @@ 4.18 if(m->init() != -1) { 4.19 /* add to the active modules array */ 4.20 vr_activate_module(i); 4.21 - if(!vrm) { 4.22 - vr_use_module(0); 4.23 - } 4.24 } 4.25 } 4.26 4.27 - if(!vrm) { 4.28 + if(!vr_get_num_active_modules()) { 4.29 return -1; 4.30 } 4.31 + 4.32 + if((vrmod_env = getenv("VR_MODULE"))) { 4.33 + vr_use_module_named(vrmod_env); 4.34 + } else { 4.35 + vr_use_module(0); 4.36 + } 4.37 return 0; 4.38 } 4.39
5.1 --- a/src/vr_libovr.c Fri Sep 19 05:30:20 2014 +0300 5.2 +++ b/src/vr_libovr.c Fri Sep 19 15:16:51 2014 +0300 5.3 @@ -162,7 +162,7 @@ 5.4 return -1; 5.5 } 5.6 5.7 -static int translation(int eye, float *vec) 5.8 +static void translation(int eye, float *vec) 5.9 { 5.10 if(!hmd) { 5.11 vec[0] = vec[1] = vec[2] = 0; 5.12 @@ -177,7 +177,7 @@ 5.13 return 1; 5.14 } 5.15 5.16 -static int rotation(int eye, float *quat) 5.17 +static void rotation(int eye, float *quat) 5.18 { 5.19 if(!hmd) { 5.20 quat[0] = quat[1] = quat[2] = 0.0f;
6.1 --- a/src/vr_openhmd.c Fri Sep 19 05:30:20 2014 +0300 6.2 +++ b/src/vr_openhmd.c Fri Sep 19 15:16:51 2014 +0300 6.3 @@ -56,6 +56,7 @@ 6.4 ohmd_device_geti(dev, OHMD_SCREEN_HORIZONTAL_SIZE, &disp_width); 6.5 ohmd_device_geti(dev, OHMD_SCREEN_VERTICAL_SIZE, &disp_height); 6.6 ohmd_device_getf(dev, OHMD_EYE_IPD, &ipd); 6.7 + ipd /= 100.0f; /* convert ipd to meters */ 6.8 6.9 if((optdb = create_options())) { 6.10 set_option_int(optdb, VR_OPT_DISPLAY_WIDTH, disp_width); 6.11 @@ -104,28 +105,23 @@ 6.12 return -1; 6.13 } 6.14 6.15 -static int translation(int eye, float *vec) 6.16 +static void translation(int eye, float *vec) 6.17 { 6.18 - float xform[16]; 6.19 + /* OpenHMD doesn't support positional tracking, so just return the eye offset */ 6.20 6.21 - view_matrix(eye, xform); 6.22 - 6.23 - vec[0] = xform[3]; 6.24 - vec[1] = xform[7]; 6.25 - vec[2] = xform[11]; 6.26 - return 0; 6.27 + vec[0] = (eye == VR_EYE_LEFT ? -ipd : ipd) / 2.0; 6.28 + vec[1] = vec[2] = 0.0f; 6.29 } 6.30 6.31 -static int rotation(int eye, float *quat) 6.32 +static void rotation(int eye, float *quat) 6.33 { 6.34 if(!dev) { 6.35 quat[0] = quat[1] = quat[2] = 0.0f; 6.36 quat[3] = 1.0f; 6.37 - return -1; 6.38 + return; 6.39 } 6.40 6.41 ohmd_device_getf(dev, OHMD_ROTATION_QUAT, quat); 6.42 - return 0; 6.43 } 6.44 6.45 6.46 @@ -136,8 +132,8 @@ 6.47 6.48 static void proj_matrix(int eye, float znear, float zfar, float *mat) 6.49 { 6.50 - ohmd_device_setf(dev, OHMD_PROJECTION_ZNEAR, znear); 6.51 - ohmd_device_setf(dev, OHMD_PROJECTION_ZFAR, zfar); 6.52 + ohmd_device_setf(dev, OHMD_PROJECTION_ZNEAR, &znear); 6.53 + ohmd_device_setf(dev, OHMD_PROJECTION_ZFAR, &zfar); 6.54 ohmd_device_getf(dev, OHMD_LEFT_EYE_GL_PROJECTION_MATRIX + eye, mat); 6.55 } 6.56 6.57 @@ -166,7 +162,9 @@ 6.58 6.59 static void recenter(void) 6.60 { 6.61 - /* TODO does OHMD support the magnetometer? */ 6.62 + /* TODO grab the current rotation quat, invert it, and use it to 6.63 + * multiply with the rotation quat query results 6.64 + */ 6.65 } 6.66 6.67 6.68 @@ -180,6 +178,8 @@ 6.69 m.cleanup = cleanup; 6.70 m.set_option = set_option; 6.71 m.get_option = get_option; 6.72 + m.translation = translation; 6.73 + m.rotation = rotation; 6.74 m.view_matrix = view_matrix; 6.75 m.proj_matrix = proj_matrix; 6.76 m.begin = begin; 6.77 @@ -187,6 +187,7 @@ 6.78 m.set_eye_texture = set_eye_texture; 6.79 m.recenter = recenter; 6.80 } 6.81 + return &m; 6.82 } 6.83 6.84 #else /* don't use OpenHMD */