oculus1
diff src/main.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 | c7b50cd7184c |
children | b069a5c27388 |
line diff
1.1 --- a/src/main.cc Fri Aug 30 06:08:34 2013 +0300 1.2 +++ b/src/main.cc Sat Sep 14 16:14:59 2013 +0300 1.3 @@ -1,5 +1,6 @@ 1.4 #include <stdio.h> 1.5 #include <stdlib.h> 1.6 +#include <string.h> 1.7 #include <assert.h> 1.8 #include <GL/glew.h> 1.9 #ifdef __APPLE__ 1.10 @@ -7,7 +8,7 @@ 1.11 #else 1.12 #include <GL/glut.h> 1.13 #endif 1.14 -#include <OVR.h> 1.15 +#include "vr.h" 1.16 #include "camera.h" 1.17 1.18 static bool init(); 1.19 @@ -17,14 +18,20 @@ 1.20 static void reshape(int x, int y); 1.21 static void keyb(unsigned char key, int x, int y); 1.22 static void sball_rotate(int rx, int ry, int rz); 1.23 +static bool parse_args(int argc, char **argv); 1.24 1.25 static Camera cam; 1.26 static int width, height; 1.27 -static OVR::DeviceManager *ovr_devman; 1.28 +static bool use_vr = false; 1.29 1.30 int main(int argc, char **argv) 1.31 { 1.32 glutInit(&argc, argv); 1.33 + 1.34 + if(!parse_args(argc, argv)) { 1.35 + return 1; 1.36 + } 1.37 + 1.38 glutInitWindowSize(1280, 800); 1.39 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 1.40 glutCreateWindow("oculus test 01"); 1.41 @@ -55,18 +62,15 @@ 1.42 glEnable(GL_LIGHT0); 1.43 glEnable(GL_LIGHTING); 1.44 1.45 - // initialize Oculus SDK 1.46 - OVR::System::Init(); 1.47 - if(!(ovr_devman = OVR::DeviceManager::Create())) { 1.48 - fprintf(stderr, "failed to create OVR device manager\n"); 1.49 + if(vr_init(VR_INIT_OCULUS) == -1) { 1.50 return false; 1.51 } 1.52 - 1.53 return true; 1.54 } 1.55 1.56 static void cleanup() 1.57 { 1.58 + vr_shutdown(); 1.59 } 1.60 1.61 static void disp() 1.62 @@ -115,3 +119,23 @@ 1.63 static void sball_rotate(int rx, int ry, int rz) 1.64 { 1.65 } 1.66 + 1.67 +static bool parse_args(int argc, char **argv) 1.68 +{ 1.69 + for(int i=1; i<argc; i++) { 1.70 + if(argv[i][0] == '-') { 1.71 + if(strcmp(argv[i], "-vr") == 0) { 1.72 + use_vr = true; 1.73 + } else if(strcmp(argv[i], "-novr") == 0) { 1.74 + use_vr = false; 1.75 + } else { 1.76 + fprintf(stderr, "invalid option: %s\n", argv[i]); 1.77 + return false; 1.78 + } 1.79 + } else { 1.80 + fprintf(stderr, "unexpected argument: %s\n", argv[i]); 1.81 + return false; 1.82 + } 1.83 + } 1.84 + return true; 1.85 +}