nuclear@5: #ifdef WIN32 nuclear@5: #define OVR_OS_WIN32 nuclear@5: #endif nuclear@5: nuclear@5: #include nuclear@5: #include nuclear@6: #include "vr_impl.h" nuclear@6: nuclear@6: #ifdef USE_LIBOVR nuclear@5: #include nuclear@5: #include nuclear@4: nuclear@5: static ovrHmd hmd; nuclear@5: nuclear@4: static int init(void) nuclear@4: { nuclear@5: int i, num_hmds; nuclear@5: union ovrGLConfig glcfg; nuclear@5: nuclear@5: if(!ovr_Initialize()) { nuclear@5: return -1; nuclear@5: } nuclear@5: printf("initialized LibOVR %s\n", ovr_GetVersionString()); nuclear@5: nuclear@5: if(!(num_hmds = ovrHmd_Detect())) { nuclear@5: ovr_Shutdown(); nuclear@5: return -1; nuclear@5: } nuclear@5: printf("%d Oculus HMD(s) found\n", num_hmds); nuclear@5: nuclear@5: hmd = 0; nuclear@5: for(i=0; iManufacturer, h->ProductName); nuclear@5: nuclear@5: if(!hmd) { nuclear@5: hmd = h; nuclear@5: } else { nuclear@5: ovrHmd_Destroy(h); nuclear@5: } nuclear@5: } nuclear@5: nuclear@5: if(!hmd) { nuclear@5: fprintf(stderr, "failed to initialize any Oculus HMDs\n"); nuclear@5: return -1; nuclear@5: } nuclear@5: nuclear@5: ovrHmd_ConfigureTracking(hmd, 0xffffffff, 0); nuclear@5: nuclear@5: glcfg.OGL.Header.API = ovrRenderAPI_OpenGL; nuclear@5: glcfg.OGL.Header.RTSize = hmd->Resolution; nuclear@5: glcfg.OGL.Header.Multisample = 0; nuclear@5: glcfg.OGL.Window = 0; nuclear@5: glcfg.OGL.DC = 0; nuclear@5: nuclear@5: if(!ovrHmd_ConfigureRendering(hmd, &glcfg.Config, distort_caps, eyes_fov, eye_rend_desc))) { nuclear@5: fprintf(stderr, "failed to configure LibOVR distortion renderer\n"); nuclear@5: return -1; nuclear@5: } nuclear@4: } nuclear@4: nuclear@4: static void cleanup(void) nuclear@4: { nuclear@5: if(hmd) { nuclear@5: ovrHmd_Destroy(hmd); nuclear@5: ovr_Destroy(); nuclear@5: } nuclear@4: } nuclear@4: nuclear@4: static void view_matrix(int eye, float *mat) nuclear@4: { nuclear@4: } nuclear@4: nuclear@4: static void proj_matrix(int eye, float *mat) nuclear@4: { nuclear@4: } nuclear@4: nuclear@5: static void begin(int eye) nuclear@4: { nuclear@4: } nuclear@4: nuclear@5: static void end(void) nuclear@5: { nuclear@5: } nuclear@5: nuclear@5: static void present(void) nuclear@5: { nuclear@5: } nuclear@5: nuclear@5: nuclear@4: struct vr_module *vr_module_libovr(void) nuclear@4: { nuclear@4: static struct vr_module m; nuclear@4: nuclear@4: if(!m.init) { nuclear@4: m.name = "libovr"; nuclear@4: m.init = init; nuclear@4: m.cleanup = cleanup; nuclear@4: m.view_matrix = view_matrix; nuclear@4: m.proj_matrix = proj_matrix; nuclear@5: m.begin = begin; nuclear@5: m.end = end; nuclear@5: m.present = present; nuclear@4: } nuclear@4: return &m; nuclear@4: } nuclear@6: nuclear@6: #else /* no libovr */ nuclear@6: nuclear@6: static int init(void) nuclear@6: { nuclear@6: return -1; nuclear@6: } nuclear@6: nuclear@6: struct vr_module *vr_module_libovr(void) nuclear@6: { nuclear@6: static struct vr_module m; nuclear@6: nuclear@6: if(!m.init) { nuclear@6: m.name = "libovr"; nuclear@6: m.init = init; nuclear@6: } nuclear@6: return &m; nuclear@6: } nuclear@6: nuclear@6: #endif /* USE_LIBOVR */