X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fapp.cc;h=764d2485b23bada404103207fe3f75272caacb94;hp=96e92f332ae7231d8e377801bfab2cc4dd106397;hb=01d6ef175190e649ecf7deb298f34f0e9bd3233e;hpb=197bafc7f54795243d4c217c2efcf41f01d4100d diff --git a/src/app.cc b/src/app.cc index 96e92f3..764d248 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) { @@ -222,6 +226,7 @@ void app_cleanup() app_grab_mouse(false); if(opt.vr) { + delete goatvr_rtarg; goatvr_shutdown(); } destroy_vrhands(); @@ -273,6 +278,21 @@ static void update(float dt) exman->update(dt); exui_update(dt); + // use goatvr sticks for joystick input + int num_vr_sticks = goatvr_num_sticks(); + if(num_vr_sticks > 0) { + float p[2]; + goatvr_stick_pos(0, p); + joy_move.x = p[0]; + joy_move.y = -p[1]; + } + if(num_vr_sticks > 1) { + float p[2]; + goatvr_stick_pos(1, p); + joy_look.x = p[0]; + } + + float speed = walk_speed * dt; Vec3 dir; @@ -421,14 +441,20 @@ 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); - if(goatvr_get_fb_texture()) { + 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; } @@ -449,7 +475,12 @@ void app_display() if(debug_gui) { ImGui::Render(); } + + if(gfbo) { + pop_render_target(RT_FAKE); + } } + goatvr_draw_done(); vp_width = win_width;