X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fapp.cc;h=44c65fd1b150e9ebcf5a86282e159c69dcd883d4;hp=ee9b5e64a4286054255c0b3618b3c1eef58b521a;hb=2829b50d6b3d9e97fc9399f5b6929f7d64021366;hpb=e5c3a6764a288f04cffbf02164fec7a2c2d80dea diff --git a/src/app.cc b/src/app.cc index ee9b5e6..44c65fd 100644 --- a/src/app.cc +++ b/src/app.cc @@ -15,6 +15,7 @@ #include "opt.h" #include "post.h" #include "renderer.h" +#include "rtarg.h" #include "avatar.h" #include "vrinput.h" #include "exman.h" @@ -82,6 +83,7 @@ static ExhibitSlot exslot_left, exslot_right; #define exslot_mouse exslot_right static Renderer *rend; +static RenderTarget *goatvr_rtarg; static Ray last_pick_ray; @@ -123,6 +125,8 @@ bool app_init(int argc, char **argv) have_handtracking = goatvr_have_handtracking(); goatvr_recenter(); + + goatvr_rtarg = new RenderTarget; } if(fb_srgb) { @@ -183,6 +187,11 @@ bool app_init(int argc, char **argv) if(!rend->init()) { return false; } + if(opt.reflect) { + rend->ropt |= RENDER_MIRRORS; + } else { + rend->ropt &= ~RENDER_MIRRORS; + } rend->set_scene(mscn); glUseProgram(0); @@ -217,6 +226,7 @@ void app_cleanup() app_grab_mouse(false); if(opt.vr) { + delete goatvr_rtarg; goatvr_shutdown(); } destroy_vrhands(); @@ -416,13 +426,23 @@ void app_display() goatvr_draw_start(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + unsigned int gfbo = goatvr_get_fbo(); + update(dt); 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); + if(gfbo) { + vp_width = goatvr_get_fb_eye_width(i); + vp_height = goatvr_get_fb_eye_height(i); + + // this is a lightweight operation + goatvr_rtarg->create_wrap_fbo(gfbo, vp_width, vp_height); + push_render_target(goatvr_rtarg, RT_FAKE); + } else { + vp_width = win_width / 2; + } proj_matrix = goatvr_projection_matrix(i, NEAR_CLIP, FAR_CLIP); glMatrixMode(GL_PROJECTION); @@ -440,7 +460,12 @@ void app_display() if(debug_gui) { ImGui::Render(); } + + if(gfbo) { + pop_render_target(RT_FAKE); + } } + goatvr_draw_done(); vp_width = win_width;