X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fapp.cc;h=30222f9ce50d57444519b7aef8e6d427dc4df427;hp=b61b0e74417a3b8bb381d53e3fcb04d34ddc4586;hb=844f36f03073c5db86a8acd2cf7cd1a89e1a16b9;hpb=74034a459f47934ef60ba295033b9cb7e597d32a diff --git a/src/app.cc b/src/app.cc index b61b0e7..30222f9 100644 --- a/src/app.cc +++ b/src/app.cc @@ -33,6 +33,7 @@ static Ray calc_pick_ray(int x, int y); long time_msec; int win_width, win_height; +int vp_width, vp_height; float win_aspect; bool fb_srgb; bool opt_gear_wireframe; @@ -166,11 +167,8 @@ bool app_init(int argc, char **argv) avatar.body_rot = rad_to_deg(acos(dot(dir, Vec3(0, 0, 1)))); exman = new ExhibitManager; - /* - if(!exman->load(mscn, "data/exhibits")) { - //return false; - } - */ + // exhibits are loaded in post_scene_init, because they need access to the scene graph + if(!exui_init()) { error_log("failed to initialize exhibit ui system\n"); return false; @@ -194,6 +192,9 @@ bool app_init(int argc, char **argv) } rend = new Renderer; + if(!rend->init()) { + return false; + } rend->set_scene(mscn); glUseProgram(0); @@ -208,8 +209,11 @@ bool app_init(int argc, char **argv) return true; } +// post_scene_init is called after the scene has completed loading static void post_scene_init() { + mscn->update(0); // update once to calculate node matrices + int num_mir = mscn->calc_mirror_planes(); info_log("found %d mirror planes\n", num_mir); @@ -429,6 +433,8 @@ void app_display() for(int i=0; i<2; i++) { // for each eye goatvr_draw_eye(i); + vp_width = goatvr_get_fb_eye_width(i); + vp_height = goatvr_get_fb_eye_height(i); proj_matrix = goatvr_projection_matrix(i, NEAR_CLIP, FAR_CLIP); glMatrixMode(GL_PROJECTION); @@ -449,6 +455,9 @@ void app_display() } goatvr_draw_done(); + vp_width = win_width; + vp_height = win_height; + if(should_swap) { app_swap_buffers(); } @@ -555,6 +564,9 @@ void app_reshape(int x, int y) glViewport(0, 0, x, y); goatvr_set_fb_size(x, y, 1.0f); debug_gui_reshape(x, y); + + vp_width = x; + vp_height = y; } void app_keyboard(int key, bool pressed)