X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=blobdiff_plain;f=src%2Fapp.cc;h=9b83c21698807cc3191178e8ed540175327aebda;hp=730302eb6a0400adda783056832bb34d93c11c24;hb=eca943b2fb891a01cb4e883c07aad2167a8ac94b;hpb=818d6e49d86bc91748396a8c408cd84d17e10994 diff --git a/src/app.cc b/src/app.cc index 730302e..9b83c21 100644 --- a/src/app.cc +++ b/src/app.cc @@ -8,24 +8,27 @@ #include "backdrop.h" #include "goatvr.h" #include "opt.h" +#include "fs.h" + +static void draw_scene(); int win_width, win_height; float win_aspect; long time_msec; +double time_sec; Mat4 view_matrix; static bool should_swap; static float cam_theta, cam_phi; static float cam_height = 1.65; -static Mesh *mesh_torus; static bool bnstate[16]; static int prev_x, prev_y; bool app_init(int argc, char **argv) { - if(!init_options(argc, argv, 0)) { + if(!init_options(argc, argv, "vrfileman.conf")) { return false; } app_resize(opt.width, opt.height); @@ -64,13 +67,14 @@ bool app_init(int argc, char **argv) Mesh::use_custom_sdr_attr = false; - mesh_torus = new Mesh; - gen_torus(mesh_torus, 1.0, 0.25, 32, 32); - if(!init_backdrop()) { return false; } + if(!init_fs()) { + return false; + } + return true; } @@ -79,7 +83,6 @@ void app_cleanup() if(opt.vr) { goatvr_shutdown(); } - delete mesh_torus; cleanup_backdrop(); } @@ -104,7 +107,7 @@ void app_draw() glMatrixMode(GL_MODELVIEW); glLoadMatrixf(view_matrix[0]); - draw_backdrop(); + draw_scene(); } goatvr_draw_done(); @@ -125,22 +128,33 @@ void app_draw() glMatrixMode(GL_MODELVIEW); glLoadMatrixf(view_matrix[0]); - draw_backdrop(); + draw_scene(); app_swap_buffers(); + app_redraw(); // since we added animation we need to redisplay even in non-VR mode } assert(glGetError() == GL_NO_ERROR); } +static void draw_scene() +{ + draw_backdrop(); + draw_fs(); +} + void app_reshape(int x, int y) { glViewport(0, 0, x, y); Mat4 mat; - mat.perspective(deg_to_rad(50), win_aspect, 0.5, 500.0); + mat.perspective(deg_to_rad(60), win_aspect, 0.5, 500.0); 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,6 +165,17 @@ 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(opt.vr) { goatvr_recenter();