From ecbcadf1e5849f2c92f12d0c8b95a495c76c5dcb Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Sun, 3 Jun 2018 22:25:58 -0400 Subject: [PATCH] update gooey debug window, remove imgui.ini files --- .gitignore | 1 + ext/aixlog | 2 +- ext/imgui | 2 +- msvc/imgui.ini | 5 ----- src/gooey.h | 44 +++++++++++++++++++++++++++++++++----------- src/hexgame.cpp | 5 +++-- src/imgui.ini | 5 ----- src/renderer.h | 30 ++++++++++-------------------- 8 files changed, 49 insertions(+), 45 deletions(-) delete mode 100644 msvc/imgui.ini delete mode 100644 src/imgui.ini diff --git a/.gitignore b/.gitignore index 2009762..50c0755 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ src/tags *.swp msvc/.vs/ msvc/x64/ +imgui.ini diff --git a/ext/aixlog b/ext/aixlog index abca753..2e5ee01 160000 --- a/ext/aixlog +++ b/ext/aixlog @@ -1 +1 @@ -Subproject commit abca7539315c902e10c06bb363c19a0e1111bc78 +Subproject commit 2e5ee0188650a254f76f7e735ef986f117dee71f diff --git a/ext/imgui b/ext/imgui index 6a25a87..948009a 160000 --- a/ext/imgui +++ b/ext/imgui @@ -1 +1 @@ -Subproject commit 6a25a8720ac27573225643a1188d8a49b4ad614e +Subproject commit 948009a8b2e98ef35fb8ddfe19299535a16c0834 diff --git a/msvc/imgui.ini b/msvc/imgui.ini deleted file mode 100644 index 3b8fc7a..0000000 --- a/msvc/imgui.ini +++ /dev/null @@ -1,5 +0,0 @@ -[Window][Debug##Default] -Pos=13,4 -Size=370,374 -Collapsed=0 - diff --git a/src/gooey.h b/src/gooey.h index 7a31bc0..7ac202e 100644 --- a/src/gooey.h +++ b/src/gooey.h @@ -13,14 +13,16 @@ bool initGooey(SDL_Handles &handles, v2i vp_dims); void shutdownGooey(); bool gooeyProcessEvent(SDL_Event &event); -void renderGooey(SDL_Handles &handles, HexDrawMode &mode); +void renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug, + hex_info* start_hex, hex_info* current_hex, bool &is_selecting); bool initGooey(SDL_Handles &handles, v2i vp_dims /*TODO: pass in game state*/) { IMGUI_CHECKVERSION(); ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; + ImGuiIO& io = ImGui::GetIO(); + io.IniFilename = NULL; // don't save window state to imgui.ini ImGui_ImplSdlGL3_Init(handles.window); io.DisplaySize.x = vp_dims.x; io.DisplaySize.y = vp_dims.y; @@ -44,11 +46,12 @@ gooeyProcessEvent(SDL_Event &event) } void -renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug) +renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug, + hex_info* start_hex, hex_info* current_hex, bool &is_selecting) { ImGui_ImplSdlGL3_NewFrame(handles.window); -#if 0 +#if 1 ImGuiWindowFlags window_flags = 0; window_flags |= ImGuiWindowFlags_NoTitleBar; window_flags |= ImGuiWindowFlags_NoScrollbar; @@ -56,28 +59,47 @@ renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug) window_flags |= ImGuiWindowFlags_NoResize; window_flags |= ImGuiWindowFlags_NoCollapse; + ImGui::SetNextWindowPos(ImVec2(0,0)); + ImGui::SetNextWindowSize(ImVec2(300, 250)); + ImGui::SetNextWindowBgAlpha(0.3f); bool show_window; ImGui::Begin("", &show_window, window_flags); #endif - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", - 1000.0f / ImGui::GetIO().Framerate, - ImGui::GetIO().Framerate); + ImGuiIO& io = ImGui::GetIO(); + ImGui::Text("%.3f ms/frame, (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); - if (ImGui::Button("None")) + ImGui::Text("Draw Mode:"); + if (ImGui::RadioButton("None", (mode == NONE))) mode = NONE; - if (ImGui::Button("Fill")) + if (ImGui::RadioButton("Fill", (mode == FILL))) mode = FILL; - if (ImGui::Button("Line")) + if (ImGui::RadioButton("Line", (mode == LINE))) mode = LINE; - if (ImGui::Button("Cone Fill")) + if (ImGui::RadioButton("Cone Fill", (mode == CONE_FILL))) mode = CONE_FILL; ImGui::Checkbox("Debug Render", &is_debug); ImGui::SameLine(); ImGui::TextUnformatted(is_debug ? "true" : "false"); + ImGui::Text("is_selecting"); + ImGui::SameLine(); ImGui::TextUnformatted(is_selecting ? "true" : "false"); + + if (current_hex) + { + Hex ch = current_hex->hex; + ImGui::Text("current_hex: %i, %i, %i", ch.q, ch.r, ch.s); + } + if (start_hex) + { + Hex sh = start_hex->hex; + ImGui::Text("start_hex: %i, %i, %i", sh.q, sh.r, sh.s); + } + + ImGui::End(); ImGui::Render(); ImGui_ImplSdlGL3_RenderDrawData(ImGui::GetDrawData()); + } #endif // GOOEY_H diff --git a/src/hexgame.cpp b/src/hexgame.cpp index 8faf551..4387473 100644 --- a/src/hexgame.cpp +++ b/src/hexgame.cpp @@ -401,7 +401,7 @@ int main(int argc, char* argv[]) g_game_state->is_selecting = false; g_game_state->start_hex = 0x0; g_game_state->current_hex = 0x0; - g_game_state->draw_mode = NONE; + g_game_state->draw_mode = LINE; // init global render state g_render_state = new render_state(); @@ -446,7 +446,8 @@ int main(int argc, char* argv[]) renderFrame(g_game_state->hex_array); if (g_render_state->is_debug_draw && g_game_state->draw_mode == CONE_FILL) renderDebug(g_game_state->start_hex, g_game_state->current_hex); - renderGooey(handles, g_game_state->draw_mode, g_render_state->is_debug_draw); + renderGooey(handles, g_game_state->draw_mode, g_render_state->is_debug_draw, + g_game_state->start_hex, g_game_state->current_hex, g_game_state->is_selecting); SDL_GL_SwapWindow(handles.window); } diff --git a/src/imgui.ini b/src/imgui.ini deleted file mode 100644 index a8ffb8c..0000000 --- a/src/imgui.ini +++ /dev/null @@ -1,5 +0,0 @@ -[Window][Debug##Default] -Pos=0,5 -Size=400,400 -Collapsed=0 - diff --git a/src/renderer.h b/src/renderer.h index dfd1ecb..dd2ae57 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -289,18 +289,18 @@ fillTriangleBufferFromHex(GLfloat buf[], int idx, const hex_info &hex) // triangles for (int i = 0; i < 6; i++) { - if (i == 5) // re-use the first point for the last triangle - { - // vertex 0 - buf[idx + 0] = (GLfloat) hex.XPos; - buf[idx + 1] = (GLfloat) hex.YPos; - buf[idx + 2] = (GLfloat) 0.f; + // vertex 0 + buf[idx + 0] = (GLfloat) hex.XPos; + buf[idx + 1] = (GLfloat) hex.YPos; + buf[idx + 2] = (GLfloat) 0.f; - // vertex 1 - buf[idx + 3] = (GLfloat) hex.vertices[i].x; - buf[idx + 4] = (GLfloat) hex.vertices[i].y; - buf[idx + 5] = (GLfloat) 0.f; + // vertex 1 + buf[idx + 3] = (GLfloat) hex.vertices[i].x; + buf[idx + 4] = (GLfloat) hex.vertices[i].y; + buf[idx + 5] = (GLfloat) 0.f; + if (i == 5) // re-use the first point for the last triangle + { // vertex 2 buf[idx + 6] = (GLfloat) hex.vertices[0].x; buf[idx + 7] = (GLfloat) hex.vertices[0].y; @@ -308,16 +308,6 @@ fillTriangleBufferFromHex(GLfloat buf[], int idx, const hex_info &hex) } else { - // vertex 0 - buf[idx + 0] = (GLfloat) hex.XPos; - buf[idx + 1] = (GLfloat) hex.YPos; - buf[idx + 2] = (GLfloat) 0.f; - - // vertex 1 - buf[idx + 3] = (GLfloat) hex.vertices[i].x; - buf[idx + 4] = (GLfloat) hex.vertices[i].y; - buf[idx + 5] = (GLfloat) 0.f; - // vertex 2 buf[idx + 6] = (GLfloat) hex.vertices[i + 1].x; buf[idx + 7] = (GLfloat) hex.vertices[i + 1].y;