exhibits
[laserbrain_demo] / src / app.cc
index 0356104..1c27685 100644 (file)
@@ -71,8 +71,6 @@ static bool show_blobs;
 
 static Renderer *rend;
 
-static bool show_debug_gui;
-
 
 bool app_init(int argc, char **argv)
 {
@@ -143,9 +141,11 @@ 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;
        }
+       */
 
        blobs = new BlobExhibit;
        blobs->node = new SceneNode;
@@ -347,7 +347,7 @@ void app_display()
        float dt = (float)(time_msec - prev_msec) / 1000.0f;
        prev_msec = time_msec;
 
-       if(show_debug_gui) {
+       if(debug_gui) {
                ImGui::GetIOPtr()->DeltaTime = dt;
                ImGui::NewFrame();
 
@@ -378,7 +378,7 @@ void app_display()
                                draw_vrhands();
                        }
 
-                       if(show_debug_gui) {
+                       if(debug_gui) {
                                ImGui::Render();
                        }
                }
@@ -408,7 +408,7 @@ void app_display()
                        glUseProgram(0);
                }
 
-               if(show_debug_gui) {
+               if(debug_gui) {
                        ImGui::Render();
                }
                app_swap_buffers();
@@ -427,10 +427,7 @@ static void draw_scene()
        set_light(2, lpos[2], Vec3(0.8, 1.0, 0.8) * 0.3);
 
        rend->draw();
-
-       if(show_blobs) {
-               blobs->draw();
-       }
+       exman->draw();
 
        /*
        if(have_handtracking) {
@@ -500,9 +497,9 @@ void app_keyboard(int key, bool pressed)
 {
        unsigned int mod = app_get_modifiers();
 
-       if(!debug_gui_key(key, pressed, mod)) {
-               // the debug gui indicated that we should ignore the event
-               return;
+       if(debug_gui && !(pressed && (key == '`' || key == 27))) {
+               debug_gui_key(key, pressed, mod);
+               return; // ignore all keystrokes when GUI is visible
        }
 
        if(pressed) {
@@ -518,12 +515,12 @@ void app_keyboard(int key, bool pressed)
                        }
                        break;
 
-               case '\t':
-                       show_debug_gui = !show_debug_gui;
-                       show_message("debug gui %s", show_debug_gui ? "enabled" : "disabled");
+               case '`':
+                       debug_gui = !debug_gui;
+                       show_message("debug gui %s", debug_gui ? "enabled" : "disabled");
                        break;
 
-               case '`':
+               case 'm':
                        app_toggle_grab_mouse();
                        show_message("mouse %s", app_is_mouse_grabbed() ? "grabbed" : "released");
                        break;
@@ -582,6 +579,11 @@ void app_keyboard(int key, bool pressed)
                        goatvr_recenter();
                        show_message("VR recenter\n");
                        break;
+
+               case 'x':
+                       exman->clear();
+                       exman->load(mscn, "data/exhibits");
+                       break;
                }
        }
 
@@ -592,9 +594,9 @@ void app_keyboard(int key, bool pressed)
 
 void app_mouse_button(int bn, bool pressed, int x, int y)
 {
-       if(!debug_gui_mbutton(bn, pressed, x, y)) {
-               // the debug GUI indicated we should ignore the event
-               return;
+       if(debug_gui) {
+               debug_gui_mbutton(bn, pressed, x, y);
+               return; // ignore mouse events while GUI is visible
        }
 
        prev_mx = x;
@@ -620,9 +622,9 @@ static void mouse_zoom(float dx, float dy)
 
 void app_mouse_motion(int x, int y)
 {
-       if(!debug_gui_mmotion(x, y)) {
-               // the debug GUI indicated we should ignore the event
-               return;
+       if(debug_gui) {
+               debug_gui_mmotion(x, y);
+               return; // ignore mouse events while GUI is visible
        }
 
        int dx = x - prev_mx;
@@ -649,6 +651,13 @@ void app_mouse_delta(int dx, int dy)
        }
 }
 
+void app_mouse_wheel(int dir)
+{
+       if(debug_gui) {
+               debug_gui_wheel(dir);
+       }
+}
+
 void app_gamepad_axis(int axis, float val)
 {
        switch(axis) {