Browse Source

update gooey debug window, remove imgui.ini files

master
cinnaboot 8 years ago
parent
commit
ecbcadf1e5
  1. 1
      .gitignore
  2. 2
      ext/aixlog
  3. 2
      ext/imgui
  4. 5
      msvc/imgui.ini
  5. 44
      src/gooey.h
  6. 5
      src/hexgame.cpp
  7. 5
      src/imgui.ini
  8. 14
      src/renderer.h

1
.gitignore vendored

@ -4,4 +4,5 @@ src/tags
*.swp *.swp
msvc/.vs/ msvc/.vs/
msvc/x64/ msvc/x64/
imgui.ini

2
ext/aixlog

@ -1 +1 @@
Subproject commit abca7539315c902e10c06bb363c19a0e1111bc78 Subproject commit 2e5ee0188650a254f76f7e735ef986f117dee71f

2
ext/imgui

@ -1 +1 @@
Subproject commit 6a25a8720ac27573225643a1188d8a49b4ad614e Subproject commit 948009a8b2e98ef35fb8ddfe19299535a16c0834

5
msvc/imgui.ini

@ -1,5 +0,0 @@
[Window][Debug##Default]
Pos=13,4
Size=370,374
Collapsed=0

44
src/gooey.h

@ -13,14 +13,16 @@
bool initGooey(SDL_Handles &handles, v2i vp_dims); bool initGooey(SDL_Handles &handles, v2i vp_dims);
void shutdownGooey(); void shutdownGooey();
bool gooeyProcessEvent(SDL_Event &event); 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 bool
initGooey(SDL_Handles &handles, v2i vp_dims /*TODO: pass in game state*/) initGooey(SDL_Handles &handles, v2i vp_dims /*TODO: pass in game state*/)
{ {
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
ImGui::CreateContext(); 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); ImGui_ImplSdlGL3_Init(handles.window);
io.DisplaySize.x = vp_dims.x; io.DisplaySize.x = vp_dims.x;
io.DisplaySize.y = vp_dims.y; io.DisplaySize.y = vp_dims.y;
@ -44,11 +46,12 @@ gooeyProcessEvent(SDL_Event &event)
} }
void 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); ImGui_ImplSdlGL3_NewFrame(handles.window);
#if 0 #if 1
ImGuiWindowFlags window_flags = 0; ImGuiWindowFlags window_flags = 0;
window_flags |= ImGuiWindowFlags_NoTitleBar; window_flags |= ImGuiWindowFlags_NoTitleBar;
window_flags |= ImGuiWindowFlags_NoScrollbar; window_flags |= ImGuiWindowFlags_NoScrollbar;
@ -56,28 +59,47 @@ renderGooey(SDL_Handles &handles, HexDrawMode &mode, bool &is_debug)
window_flags |= ImGuiWindowFlags_NoResize; window_flags |= ImGuiWindowFlags_NoResize;
window_flags |= ImGuiWindowFlags_NoCollapse; window_flags |= ImGuiWindowFlags_NoCollapse;
ImGui::SetNextWindowPos(ImVec2(0,0));
ImGui::SetNextWindowSize(ImVec2(300, 250));
ImGui::SetNextWindowBgAlpha(0.3f);
bool show_window; bool show_window;
ImGui::Begin("", &show_window, window_flags); ImGui::Begin("", &show_window, window_flags);
#endif #endif
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ImGuiIO& io = ImGui::GetIO();
1000.0f / ImGui::GetIO().Framerate, ImGui::Text("%.3f ms/frame, (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGui::GetIO().Framerate);
if (ImGui::Button("None")) ImGui::Text("Draw Mode:");
if (ImGui::RadioButton("None", (mode == NONE)))
mode = NONE; mode = NONE;
if (ImGui::Button("Fill")) if (ImGui::RadioButton("Fill", (mode == FILL)))
mode = FILL; mode = FILL;
if (ImGui::Button("Line")) if (ImGui::RadioButton("Line", (mode == LINE)))
mode = LINE; mode = LINE;
if (ImGui::Button("Cone Fill")) if (ImGui::RadioButton("Cone Fill", (mode == CONE_FILL)))
mode = CONE_FILL; mode = CONE_FILL;
ImGui::Checkbox("Debug Render", &is_debug); ImGui::Checkbox("Debug Render", &is_debug);
ImGui::SameLine(); ImGui::TextUnformatted(is_debug ? "true" : "false"); 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::Render();
ImGui_ImplSdlGL3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplSdlGL3_RenderDrawData(ImGui::GetDrawData());
} }
#endif // GOOEY_H #endif // GOOEY_H

5
src/hexgame.cpp

@ -401,7 +401,7 @@ int main(int argc, char* argv[])
g_game_state->is_selecting = false; g_game_state->is_selecting = false;
g_game_state->start_hex = 0x0; g_game_state->start_hex = 0x0;
g_game_state->current_hex = 0x0; g_game_state->current_hex = 0x0;
g_game_state->draw_mode = NONE; g_game_state->draw_mode = LINE;
// init global render state // init global render state
g_render_state = new render_state(); g_render_state = new render_state();
@ -446,7 +446,8 @@ int main(int argc, char* argv[])
renderFrame(g_game_state->hex_array); renderFrame(g_game_state->hex_array);
if (g_render_state->is_debug_draw && g_game_state->draw_mode == CONE_FILL) 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); 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); SDL_GL_SwapWindow(handles.window);
} }

5
src/imgui.ini

@ -1,5 +0,0 @@
[Window][Debug##Default]
Pos=0,5
Size=400,400
Collapsed=0

14
src/renderer.h

@ -288,8 +288,6 @@ fillTriangleBufferFromHex(GLfloat buf[], int idx, const hex_info &hex)
{ {
// triangles // triangles
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{
if (i == 5) // re-use the first point for the last triangle
{ {
// vertex 0 // vertex 0
buf[idx + 0] = (GLfloat) hex.XPos; buf[idx + 0] = (GLfloat) hex.XPos;
@ -301,6 +299,8 @@ fillTriangleBufferFromHex(GLfloat buf[], int idx, const hex_info &hex)
buf[idx + 4] = (GLfloat) hex.vertices[i].y; buf[idx + 4] = (GLfloat) hex.vertices[i].y;
buf[idx + 5] = (GLfloat) 0.f; buf[idx + 5] = (GLfloat) 0.f;
if (i == 5) // re-use the first point for the last triangle
{
// vertex 2 // vertex 2
buf[idx + 6] = (GLfloat) hex.vertices[0].x; buf[idx + 6] = (GLfloat) hex.vertices[0].x;
buf[idx + 7] = (GLfloat) hex.vertices[0].y; buf[idx + 7] = (GLfloat) hex.vertices[0].y;
@ -308,16 +308,6 @@ fillTriangleBufferFromHex(GLfloat buf[], int idx, const hex_info &hex)
} }
else 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 // vertex 2
buf[idx + 6] = (GLfloat) hex.vertices[i + 1].x; buf[idx + 6] = (GLfloat) hex.vertices[i + 1].x;
buf[idx + 7] = (GLfloat) hex.vertices[i + 1].y; buf[idx + 7] = (GLfloat) hex.vertices[i + 1].y;

Loading…
Cancel
Save