X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fdbg_gui.cc;h=6a6511fa88d5962779fdc1b6d77d60e2fda28e09;hp=c0c798423d02897923a0c5a15eaf4573f0da561b;hb=da8e3a1dd04a5ac29bcaa9582430c58a769ac571;hpb=d29eba477666f0753170d9ad549a4715ce071d04 diff --git a/src/dbg_gui.cc b/src/dbg_gui.cc index c0c7984..6a6511f 100644 --- a/src/dbg_gui.cc +++ b/src/dbg_gui.cc @@ -1,3 +1,4 @@ +#include #include "dbg_gui.h" #include "imgui/imgui.h" #include "app.h" @@ -6,6 +7,9 @@ static void render_func(ImDrawData *ddat); +bool debug_gui, parent_expanded; +SceneNode *dbg_sel_node; + static ImGuiIO *io; static Texture *tex; @@ -16,6 +20,26 @@ bool init_debug_gui() io->DisplaySize.y = win_height; io->RenderDrawListsFn = render_func; + io->KeyMap[ImGuiKey_Tab] = '\t'; + io->KeyMap[ImGuiKey_LeftArrow] = KEY_LEFT; + io->KeyMap[ImGuiKey_RightArrow] = KEY_RIGHT; + io->KeyMap[ImGuiKey_UpArrow] = KEY_UP; + io->KeyMap[ImGuiKey_DownArrow] = KEY_DOWN; + io->KeyMap[ImGuiKey_PageUp] = KEY_PGUP; + io->KeyMap[ImGuiKey_PageDown] = KEY_PGDOWN; + io->KeyMap[ImGuiKey_Home] = KEY_HOME; + io->KeyMap[ImGuiKey_End] = KEY_END; + io->KeyMap[ImGuiKey_Delete] = KEY_DEL; + io->KeyMap[ImGuiKey_Backspace] = '\b'; + io->KeyMap[ImGuiKey_Enter] = '\n'; + io->KeyMap[ImGuiKey_Escape] = 27; + io->KeyMap[ImGuiKey_A] = 'a'; + io->KeyMap[ImGuiKey_C] = 'c'; + io->KeyMap[ImGuiKey_V] = 'v'; + io->KeyMap[ImGuiKey_X] = 'x'; + io->KeyMap[ImGuiKey_Y] = 'y'; + io->KeyMap[ImGuiKey_Z] = 'z'; + unsigned char *pixels; int width, height; io->Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); @@ -42,32 +66,37 @@ void debug_gui_reshape(int x, int y) io->DisplaySize.y = y; } -bool debug_gui_key(int key, bool press, unsigned int modstate) +void debug_gui_key(int key, bool press, unsigned int modstate) { - io->KeysDown[key] = press; + if(key < 512) { + io->KeysDown[key] = press; + } io->KeyShift = (modstate & MOD_SHIFT) != 0; io->KeyCtrl = (modstate & MOD_CTRL) != 0; io->KeyAlt = (modstate & MOD_ALT) != 0; io->KeySuper = false; - return true; // TODO + if(press && key < 256 && isprint(key)) { + io->AddInputCharacter(key); + } } -bool debug_gui_mbutton(int bn, bool press, int x, int y) +void debug_gui_mbutton(int bn, bool press, int x, int y) { io->MouseDown[bn] = press; io->MousePos.x = x; io->MousePos.y = y; - - return true; // TODO } -bool debug_gui_mmotion(int x, int y) +void debug_gui_mmotion(int x, int y) { io->MousePos.x = x; io->MousePos.y = y; +} - return true; // TODO +void debug_gui_wheel(int dir) +{ + io->MouseWheel = dir; } static void render_func(ImDrawData *ddat) @@ -120,7 +149,12 @@ static void render_func(ImDrawData *ddat) glTexCoordPointer(2, GL_FLOAT, sizeof *vbuf, &vbuf[0].uv); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof *vbuf, &vbuf[0].col); - glDrawElements(GL_TRIANGLES, cmd->ElemCount, GL_UNSIGNED_SHORT, ibuf); + if(glcaps.draw_range) { + int max_vidx = cmdlist->VtxBuffer.Size - 1; + glDrawRangeElements(GL_TRIANGLES, 0, max_vidx, cmd->ElemCount, GL_UNSIGNED_SHORT, ibuf); + } else { + glDrawElements(GL_TRIANGLES, cmd->ElemCount, GL_UNSIGNED_SHORT, ibuf); + } glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);