X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=blobdiff_plain;f=src%2Fapp.cc;h=c3f6b3928c57400a9f04490d01cf4f2c0f4b3b0f;hp=0dc88f01072b69c5a65b15310a9a820969f4b938;hb=8afeabf06c79c755e5aaffa224e06c4abc92d833;hpb=cb2703917746784c4ea3408a049ff4297dfc268e diff --git a/src/app.cc b/src/app.cc index 0dc88f0..c3f6b39 100644 --- a/src/app.cc +++ b/src/app.cc @@ -7,15 +7,14 @@ #include "meshgen.h" #include "backdrop.h" #include "goatvr.h" - -static bool parse_args(int argc, char **argv); +#include "opt.h" int win_width, win_height; float win_aspect; long time_msec; +double time_sec; Mat4 view_matrix; -static bool use_vr; static bool should_swap; static float cam_theta, cam_phi; @@ -27,9 +26,12 @@ static int prev_x, prev_y; bool app_init(int argc, char **argv) { - if(!parse_args(argc, argv)) { + if(!init_options(argc, argv, 0)) { return false; } + app_resize(opt.width, opt.height); + app_fullscreen(opt.fullscreen); + if(init_opengl() == -1) { return false; } @@ -44,14 +46,13 @@ bool app_init(int argc, char **argv) glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); - //glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - if(GLEW_ARB_framebuffer_sRGB) { + if(opt.srgb && GLEW_ARB_framebuffer_sRGB) { + printf("enabling sRGB framebuffer\n"); glEnable(GL_FRAMEBUFFER_SRGB); } - if(use_vr) { + if(opt.vr) { if(goatvr_init() == -1) { return false; } @@ -76,7 +77,7 @@ bool app_init(int argc, char **argv) void app_cleanup() { - if(use_vr) { + if(opt.vr) { goatvr_shutdown(); } delete mesh_torus; @@ -85,7 +86,7 @@ void app_cleanup() void app_draw() { - if(use_vr) { + if(opt.vr) { // VR mode goatvr_draw_start(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -128,6 +129,7 @@ void app_draw() draw_backdrop(); app_swap_buffers(); + app_redraw(); // since we added animation we need to redisplay even in non-VR mode } assert(glGetError() == GL_NO_ERROR); } @@ -141,6 +143,10 @@ void app_reshape(int x, int y) glMatrixMode(GL_PROJECTION); glLoadMatrixf(mat[0]); + + if(opt.vr) { + goatvr_set_fb_size(x, y, 1.0); + } } void app_keyboard(int key, bool pressed) @@ -151,8 +157,19 @@ void app_keyboard(int key, bool pressed) app_quit(); break; + case 'f': + if(!opt.vr || should_swap) { + /* we take the need to swap as a signal that our window is not managed + * by some VR compositor, and therefore it's safe to fullscreen without + * upsetting the VR rendering output + */ + opt.fullscreen = !opt.fullscreen; + app_fullscreen(opt.fullscreen); + } + break; + case ' ': - if(use_vr) { + if(opt.vr) { goatvr_recenter(); } break; @@ -179,7 +196,7 @@ void app_mouse_motion(int x, int y) if(bnstate[0]) { cam_theta += dx * 0.5; - if(!use_vr || !goatvr_have_headtracking()) { + if(!opt.vr || !goatvr_have_headtracking()) { cam_phi += dy * 0.5; if(cam_phi < -90) cam_phi = -90; @@ -188,30 +205,3 @@ void app_mouse_motion(int x, int y) } app_redraw(); } - -static bool parse_args(int argc, char **argv) -{ - for(int i=1; i