# HG changeset patch # User John Tsiombikas # Date 1393458012 -7200 # Node ID 6236080aaea4342bb7256bde66ac423fefc444df # Parent 0ac499409edd8fa9c388c93434b10c0c5cc680f0 LIBOVR conditional compilation fix diff -r 0ac499409edd -r 6236080aaea4 examples/viewscn/src/main.cc --- a/examples/viewscn/src/main.cc Tue Feb 25 23:47:48 2014 +0200 +++ b/examples/viewscn/src/main.cc Thu Feb 27 01:40:12 2014 +0200 @@ -87,9 +87,9 @@ //setup_gl_matrices(); - bind_shader(sdr); + goatgfx::bind_shader(sdr); scn->draw(); - bind_shader(0); + goatgfx::bind_shader(0); /*glBegin(GL_QUADS); glColor3f(1, 1, 1); diff -r 0ac499409edd -r 6236080aaea4 goat3dgfx.sln --- a/goat3dgfx.sln Tue Feb 25 23:47:48 2014 +0200 +++ b/goat3dgfx.sln Thu Feb 27 01:40:12 2014 +0200 @@ -9,6 +9,9 @@ EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "viewscn", "examples\viewscn\viewscn.vcproj", "{7240C31B-8746-4816-AE13-BF0F75228411}" + ProjectSection(ProjectDependencies) = postProject + {251F8AFF-5A37-4F10-A519-C55C40E127AF} = {251F8AFF-5A37-4F10-A519-C55C40E127AF} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff -r 0ac499409edd -r 6236080aaea4 goat3dgfx.vcproj --- a/goat3dgfx.vcproj Tue Feb 25 23:47:48 2014 +0200 +++ b/goat3dgfx.vcproj Thu Feb 27 01:40:12 2014 +0200 @@ -25,6 +25,7 @@ > + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 0ac499409edd -r 6236080aaea4 src/vr/vr.cc --- a/src/vr/vr.cc Tue Feb 25 23:47:48 2014 +0200 +++ b/src/vr/vr.cc Thu Feb 27 01:40:12 2014 +0200 @@ -1,5 +1,11 @@ +#include "config.h" + #include +#include +#define _USE_MATH_DEFINES +#include #include +#include "vmath/vmath.h" #include "vr.h" #include "vr_impl.h" #include "vr_sdr.h" @@ -35,8 +41,10 @@ extern "C" void vr_shutdown(void) { delete [] vr_ctx.info.display; +#ifdef USE_LIBOVR delete vr_ctx.ovr_sfusion; //System::Destroy(); +#endif memset(&vr_ctx, 0, sizeof vr_ctx); } @@ -53,6 +61,7 @@ static bool init_ovr() { +#ifdef USE_LIBOVR LogMaskConstants log_level = LogMask_All; // initialize Oculus SDK const char *logenv = getenv("VR_LOGLEVEL"); @@ -150,6 +159,7 @@ vr_ctx.ovr_sfusion = new SensorFusion; vr_ctx.ovr_sfusion->AttachToSensor(vr_ctx.ovr_sensor_dev); } +#endif // USE_LIBOVR return true; } @@ -289,12 +299,16 @@ extern "C" void vr_set_prediction_sec(float dt) { +#ifdef USE_LIBOVR vr_ctx.ovr_sfusion->SetPrediction(dt); +#endif } extern "C" float vr_get_prediction_sec(void) { +#ifdef USE_LIBOVR return vr_ctx.ovr_sfusion->GetPredictionDelta(); +#endif } extern "C" void vr_get_view_matrix(float *res, int eye) @@ -304,12 +318,19 @@ extern "C" void vr_get_proj_matrix(float *res, int eye) { +#ifdef USE_LIBOVR static float eye_scale[] = {0.0, 1.0, -1.0}; Matrix4f proj = Matrix4f::PerspectiveRH(vr_ctx.info.fov, vr_ctx.info.aspect / 2.0, 0.3, 1000.0); proj = Matrix4f::Translation(vr_ctx.info.proj_center_offset * eye_scale[eye], 0, 0) * proj; memcpy(res, proj.M[0], 16 * sizeof(float)); +#else + Matrix4x4 proj; + proj.set_perspective(vr_ctx.info.fov, vr_ctx.info.aspect, 0.3, 1000.0); + proj.transpose(); + memcpy(res, proj[0], 16 * sizeof(float)); +#endif } extern "C" void vr_get_translation(float *offs) @@ -320,17 +341,26 @@ extern "C" void vr_get_rotation(float *quat) { +#ifdef USE_LIBOVR Quatf oq = vr_ctx.ovr_sfusion->GetPredictedOrientation(); quat[0] = oq.x; quat[1] = oq.y; quat[2] = oq.z; quat[3] = oq.w; +#else + quat[0] = quat[1] = quat[2] = 0.0; + quat[3] = 1.0; +#endif } extern "C" void vr_get_rotation_euler(float *euler) { +#ifdef USE_LIBOVR Quatf oq = vr_ctx.ovr_sfusion->GetPredictedOrientation(); oq.GetEulerAngles(euler + 1, euler, euler + 2); +#else + euler[0] = euler[1] = euler[2] = 0.0; +#endif } extern "C" void vr_draw_eye(int eye, unsigned int tex, float tex_scale_x, float tex_scale_y) diff -r 0ac499409edd -r 6236080aaea4 src/vr/vr_impl.h --- a/src/vr/vr_impl.h Tue Feb 25 23:47:48 2014 +0200 +++ b/src/vr/vr_impl.h Thu Feb 27 01:40:12 2014 +0200 @@ -1,15 +1,21 @@ #ifndef VR_IMPL_H_ #define VR_IMPL_H_ +#include "config.h" + +#ifdef USE_LIBOVR #include using namespace OVR; +#endif struct VRContext { +#ifdef USE_LIBOVR DeviceManager *ovr_devman; HMDDevice *ovr_hmd_dev; SensorDevice *ovr_sensor_dev; SensorFusion *ovr_sfusion; +#endif struct { char *display;