oculus1
view src/vr.cc @ 1:e2f9e4603129
added LibOVR and started a simple vr wrapper.
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Sep 2013 16:14:59 +0300 |
parents | |
children | b069a5c27388 |
line source
1 #include <stdio.h>
2 #include "vr.h"
3 #include "vr_impl.h"
5 static bool init_ovr();
7 VRData vr_data;
9 extern "C" int vr_init(enum vr_init_mode mode)
10 {
11 if(!init_ovr()) {
12 return -1;
13 }
14 return 0;
15 }
17 extern "C" void vr_shutdown(void)
18 {
19 System::Destroy();
20 }
24 static bool init_ovr()
25 {
26 // initialize Oculus SDK
27 System::Init();
28 if(!(vr_data.ovr_devman = DeviceManager::Create())) {
29 fprintf(stderr, "failed to create OVR device manager\n");
30 return false;
31 }
33 // create the display device
34 if(!(vr_data.ovr_hmd_dev = vr_data.ovr_devman->EnumerateDevices<HMDDevice>().CreateDevice())) {
35 fprintf(stderr, "no oculus rift devices found\n");
36 return false;
37 }
39 HMDInfo info;
40 if(vr_data.ovr_hmd_dev->GetDeviceInfo(&info)) {
41 printf("oculus device info:\n");
42 printf(" name: %s\n", info.DisplayDeviceName);
43 printf(" ipd: %f\n", info.InterpupillaryDistance);
44 printf(" distortion: %f %f %f %f\n", info.DistortionK[0],
45 info.DistortionK[1], info.DistortionK[2], info.DistortionK[3]);
46 }
48 // get the sensor device
49 if(!(vr_data.ovr_sensor_dev = vr_data.ovr_hmd_dev->GetSensor())) {
50 fprintf(stderr, "failed to get oculus sensor device\n");
51 return false;
52 }
54 SensorInfo sinfo;
55 if(vr_data.ovr_sensor_dev->GetDeviceInfo(&sinfo)) {
56 printf("oculus sensor device info:\n");
57 printf(" name: %s\n", sinfo.ProductName);
58 }
60 return true;
61 }