X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fapp.cc;h=a03fd34f9bb703a80ad76ea5ac86dd5555fa6007;hp=ac6edd921b3bde2cb5de1b82dce69e8f441a7208;hb=512acaa2427ffa2ff19079f999bc2fcd7cd33925;hpb=59af92c432928d1a325393472cb8ec7a4a1594ad diff --git a/src/app.cc b/src/app.cc index ac6edd9..a03fd34 100644 --- a/src/app.cc +++ b/src/app.cc @@ -18,6 +18,7 @@ #include "vrinput.h" #include "exman.h" #include "blob_exhibit.h" +#include "dbg_gui.h" #define NEAR_CLIP 5.0 #define FAR_CLIP 10000.0 @@ -70,6 +71,8 @@ static bool show_blobs; static Renderer *rend; +static bool show_debug_gui; + bool app_init(int argc, char **argv) { @@ -112,6 +115,10 @@ bool app_init(int argc, char **argv) glEnable(GL_LIGHTING); glEnable(GL_NORMALIZE); + if(!init_debug_gui()) { + return false; + } + Mesh::use_custom_sdr_attr = false; float ambient[] = {0.0, 0.0, 0.0, 0.0}; @@ -199,6 +206,8 @@ void app_cleanup() texman.clear(); sceneman.clear(); + + cleanup_debug_gui(); } static bool constrain_walk_mesh(const Vec3 &v, Vec3 *newv) @@ -338,6 +347,13 @@ void app_display() float dt = (float)(time_msec - prev_msec) / 1000.0f; prev_msec = time_msec; + if(show_debug_gui) { + ImGui::GetIOPtr()->DeltaTime = dt; + ImGui::NewFrame(); + + ImGui::ShowTestWindow(); + } + if(opt.vr) { // VR mode goatvr_draw_start(); @@ -361,6 +377,10 @@ void app_display() if(have_handtracking) { draw_vrhands(); } + + if(show_debug_gui) { + ImGui::Render(); + } } goatvr_draw_done(); @@ -387,6 +407,10 @@ void app_display() slow_post(sdr_post_gamma); glUseProgram(0); } + + if(show_debug_gui) { + ImGui::Render(); + } app_swap_buffers(); } assert(glGetError() == GL_NO_ERROR); @@ -469,12 +493,18 @@ 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); } void app_keyboard(int key, bool pressed) { unsigned int mod = app_get_modifiers(); + if(show_debug_gui && !(pressed && (key == '`' || key == 27))) { + debug_gui_key(key, pressed, mod); + return; // ignore all keystrokes when GUI is visible + } + if(pressed) { switch(key) { case 27: @@ -489,6 +519,11 @@ void app_keyboard(int key, bool pressed) break; case '`': + show_debug_gui = !show_debug_gui; + show_message("debug gui %s", show_debug_gui ? "enabled" : "disabled"); + break; + + case 'm': app_toggle_grab_mouse(); show_message("mouse %s", app_is_mouse_grabbed() ? "grabbed" : "released"); break; @@ -557,6 +592,11 @@ void app_keyboard(int key, bool pressed) void app_mouse_button(int bn, bool pressed, int x, int y) { + if(show_debug_gui) { + debug_gui_mbutton(bn, pressed, x, y); + return; // ignore mouse events while GUI is visible + } + prev_mx = x; prev_my = y; bnstate[bn] = pressed; @@ -580,6 +620,11 @@ static void mouse_zoom(float dx, float dy) void app_mouse_motion(int x, int y) { + if(show_debug_gui) { + debug_gui_mmotion(x, y); + return; // ignore mouse events while GUI is visible + } + int dx = x - prev_mx; int dy = y - prev_my; prev_mx = x; @@ -604,6 +649,13 @@ void app_mouse_delta(int dx, int dy) } } +void app_mouse_wheel(int dir) +{ + if(show_debug_gui) { + debug_gui_wheel(dir); + } +} + void app_gamepad_axis(int axis, float val) { switch(axis) {