libgoatvr
diff src/vr_libovr.c @ 9:d12592558809
build on macosx
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 20 Sep 2014 16:52:42 +0300 |
parents | 6896f9cf9621 |
children | 34d4643d61f9 |
line diff
1.1 --- a/src/vr_libovr.c Sat Sep 20 13:22:53 2014 +0300 1.2 +++ b/src/vr_libovr.c Sat Sep 20 16:52:42 2014 +0300 1.3 @@ -1,12 +1,16 @@ 1.4 #ifdef WIN32 1.5 #define OVR_OS_WIN32 1.6 #endif 1.7 +#ifdef __APPLE__ 1.8 +#define OVR_OS_MAC 1.9 +#endif 1.10 1.11 #include "vr_impl.h" 1.12 1.13 #ifdef USE_LIBOVR 1.14 #include <stdio.h> 1.15 #include <stdlib.h> 1.16 +#include <string.h> 1.17 #include <assert.h> 1.18 #include "opt.h" 1.19 1.20 @@ -30,6 +34,7 @@ 1.21 static int init(void) 1.22 { 1.23 int i, num_hmds; 1.24 + int use_fake = 0; 1.25 1.26 if(!ovr_Initialize()) { 1.27 return -1; 1.28 @@ -37,15 +42,20 @@ 1.29 printf("initialized LibOVR %s\n", ovr_GetVersionString()); 1.30 1.31 if(!(num_hmds = ovrHmd_Detect())) { 1.32 - ovr_Shutdown(); 1.33 - return -1; 1.34 + if(getenv("VR_LIBOVR_FAKE")) { 1.35 + use_fake = 1; 1.36 + num_hmds = 1; 1.37 + } else { 1.38 + ovr_Shutdown(); 1.39 + return -1; 1.40 + } 1.41 } 1.42 printf("%d Oculus HMD(s) found\n", num_hmds); 1.43 1.44 hmd = 0; 1.45 for(i=0; i<num_hmds; i++) { 1.46 - ovrHmd h; 1.47 - if(!(h = ovrHmd_Create(i))) { 1.48 + ovrHmd h = use_fake ? ovrHmd_CreateDebug(ovrHmd_DK2) : ovrHmd_Create(i); 1.49 + if(!h) { 1.50 break; 1.51 } 1.52 printf(" [%d]: %s - %s\n", i, h->Manufacturer, h->ProductName); 1.53 @@ -166,15 +176,13 @@ 1.54 { 1.55 if(!hmd) { 1.56 vec[0] = vec[1] = vec[2] = 0; 1.57 - return 0; 1.58 + return; 1.59 } 1.60 1.61 pose[eye] = ovrHmd_GetEyePose(hmd, eye == VR_EYE_LEFT ? ovrEye_Left : ovrEye_Right); 1.62 vec[0] = pose[eye].Position.x + eye_render_desc[eye].ViewAdjust.x; 1.63 vec[1] = pose[eye].Position.y + eye_render_desc[eye].ViewAdjust.y; 1.64 vec[2] = pose[eye].Position.z + eye_render_desc[eye].ViewAdjust.z; 1.65 - 1.66 - return 1; 1.67 } 1.68 1.69 static void rotation(int eye, float *quat) 1.70 @@ -182,7 +190,7 @@ 1.71 if(!hmd) { 1.72 quat[0] = quat[1] = quat[2] = 0.0f; 1.73 quat[3] = 1.0f; 1.74 - return 0; 1.75 + return; 1.76 } 1.77 1.78 pose[eye] = ovrHmd_GetEyePose(hmd, eye == VR_EYE_LEFT ? ovrEye_Left : ovrEye_Right); 1.79 @@ -190,7 +198,6 @@ 1.80 quat[1] = pose[eye].Orientation.y; 1.81 quat[2] = pose[eye].Orientation.z; 1.82 quat[3] = pose[eye].Orientation.w; 1.83 - return 1; 1.84 } 1.85 1.86 static const float idmat[] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};