# HG changeset patch # User John Tsiombikas # Date 1411129011 -10800 # Node ID 6896f9cf96210fe5fa4657201c5a644dd4eba9de # Parent b71314e80654a078b490697075fa8283a6d0ea13 - 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 diff -r b71314e80654 -r 6896f9cf9621 Makefile.in --- a/Makefile.in Fri Sep 19 05:30:20 2014 +0300 +++ b/Makefile.in Fri Sep 19 15:16:51 2014 +0300 @@ -11,7 +11,7 @@ endif ifdef use_openhmd mod_cflags += -DUSE_OPENHMD - mod_libs += -lhmd + mod_libs += -lopenhmd endif CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic) $(mod_cflags) @@ -30,11 +30,17 @@ endif .PHONY: all -all: $(lib_so) $(lib_a) +all: $(lib_so) $(lib_a) $(soname) $(ldname) $(lib_so): $(obj) $(CC) -o $@ $(shared) $(obj) $(LDFLAGS) +$(soname): $(lib_so) + ln -sf $< $@ + +$(ldname): $(soname) + ln -sf $< $@ + $(lib_a): $(obj) $(AR) rcs $@ $(obj) @@ -45,7 +51,7 @@ .PHONY: clean clean: - rm -f $(obj) $(bin) + rm -f $(obj) $(lib_so) $(lib_a) $(soname) $(ldname) .PHONY: cleandep cleandep: clean diff -r b71314e80654 -r 6896f9cf9621 configure --- a/configure Fri Sep 19 05:30:20 2014 +0300 +++ b/configure Fri Sep 19 15:16:51 2014 +0300 @@ -6,7 +6,11 @@ use_libovr=true use_openhmd=false # not done +echo "$0 \\" >config.status +chmod +x config.status + while [ $# != 0 ]; do + echo "$1 \\" >>config.status case $1 in --prefix=*) value=`echo $arg | sed 's/--prefix=//'` @@ -57,6 +61,8 @@ shift done +echo >>config.status + echo 'Configuring libgoatvr...' echo " install prefix: $prefix" echo ' optimizations: ' `$opt && echo yes || echo no` diff -r b71314e80654 -r 6896f9cf9621 example/Makefile --- a/example/Makefile Fri Sep 19 05:30:20 2014 +0300 +++ b/example/Makefile Fri Sep 19 15:16:51 2014 +0300 @@ -3,10 +3,10 @@ bin = test vrlib_root = .. -vrlib = $(vrlib_root)/libgoatvr.a +vrlib = $(vrlib_root)/libgoatvr.so CFLAGS = -pedantic -Wall -g `pkg-config --cflags sdl2` -I$(vrlib_root)/src -LDFLAGS = $(libgl) `pkg-config --libs sdl2` $(vrlib) +LDFLAGS = $(libgl) `pkg-config --libs sdl2` -L$(vrlib_root) -lgoatvr -Wl,-rpath=$(vrlib_root) ifeq ($(shell uname -s), Darwin) libgl = -framework OpenGL -lGLEW diff -r b71314e80654 -r 6896f9cf9621 src/vr.c --- a/src/vr.c Fri Sep 19 05:30:20 2014 +0300 +++ b/src/vr.c Fri Sep 19 15:16:51 2014 +0300 @@ -1,4 +1,5 @@ #include +#include #include #include "opengl.h" #include "vr.h" @@ -31,6 +32,7 @@ int vr_init(void) { int i, nmodules; + char *vrmod_env; /* create the default options database */ if(!defopt && (defopt = create_options())) { @@ -50,15 +52,18 @@ if(m->init() != -1) { /* add to the active modules array */ vr_activate_module(i); - if(!vrm) { - vr_use_module(0); - } } } - if(!vrm) { + if(!vr_get_num_active_modules()) { return -1; } + + if((vrmod_env = getenv("VR_MODULE"))) { + vr_use_module_named(vrmod_env); + } else { + vr_use_module(0); + } return 0; } diff -r b71314e80654 -r 6896f9cf9621 src/vr_libovr.c --- a/src/vr_libovr.c Fri Sep 19 05:30:20 2014 +0300 +++ b/src/vr_libovr.c Fri Sep 19 15:16:51 2014 +0300 @@ -162,7 +162,7 @@ return -1; } -static int translation(int eye, float *vec) +static void translation(int eye, float *vec) { if(!hmd) { vec[0] = vec[1] = vec[2] = 0; @@ -177,7 +177,7 @@ return 1; } -static int rotation(int eye, float *quat) +static void rotation(int eye, float *quat) { if(!hmd) { quat[0] = quat[1] = quat[2] = 0.0f; diff -r b71314e80654 -r 6896f9cf9621 src/vr_openhmd.c --- a/src/vr_openhmd.c Fri Sep 19 05:30:20 2014 +0300 +++ b/src/vr_openhmd.c Fri Sep 19 15:16:51 2014 +0300 @@ -56,6 +56,7 @@ ohmd_device_geti(dev, OHMD_SCREEN_HORIZONTAL_SIZE, &disp_width); ohmd_device_geti(dev, OHMD_SCREEN_VERTICAL_SIZE, &disp_height); ohmd_device_getf(dev, OHMD_EYE_IPD, &ipd); + ipd /= 100.0f; /* convert ipd to meters */ if((optdb = create_options())) { set_option_int(optdb, VR_OPT_DISPLAY_WIDTH, disp_width); @@ -104,28 +105,23 @@ return -1; } -static int translation(int eye, float *vec) +static void translation(int eye, float *vec) { - float xform[16]; + /* OpenHMD doesn't support positional tracking, so just return the eye offset */ - view_matrix(eye, xform); - - vec[0] = xform[3]; - vec[1] = xform[7]; - vec[2] = xform[11]; - return 0; + vec[0] = (eye == VR_EYE_LEFT ? -ipd : ipd) / 2.0; + vec[1] = vec[2] = 0.0f; } -static int rotation(int eye, float *quat) +static void rotation(int eye, float *quat) { if(!dev) { quat[0] = quat[1] = quat[2] = 0.0f; quat[3] = 1.0f; - return -1; + return; } ohmd_device_getf(dev, OHMD_ROTATION_QUAT, quat); - return 0; } @@ -136,8 +132,8 @@ static void proj_matrix(int eye, float znear, float zfar, float *mat) { - ohmd_device_setf(dev, OHMD_PROJECTION_ZNEAR, znear); - ohmd_device_setf(dev, OHMD_PROJECTION_ZFAR, zfar); + ohmd_device_setf(dev, OHMD_PROJECTION_ZNEAR, &znear); + ohmd_device_setf(dev, OHMD_PROJECTION_ZFAR, &zfar); ohmd_device_getf(dev, OHMD_LEFT_EYE_GL_PROJECTION_MATRIX + eye, mat); } @@ -166,7 +162,9 @@ static void recenter(void) { - /* TODO does OHMD support the magnetometer? */ + /* TODO grab the current rotation quat, invert it, and use it to + * multiply with the rotation quat query results + */ } @@ -180,6 +178,8 @@ m.cleanup = cleanup; m.set_option = set_option; m.get_option = get_option; + m.translation = translation; + m.rotation = rotation; m.view_matrix = view_matrix; m.proj_matrix = proj_matrix; m.begin = begin; @@ -187,6 +187,7 @@ m.set_eye_texture = set_eye_texture; m.recenter = recenter; } + return &m; } #else /* don't use OpenHMD */