diff --git a/src/main.cc b/src/main.cc index 0439d87..9016598 100644 --- a/src/main.cc +++ b/src/main.cc @@ -149,6 +149,8 @@ int main(void) double frame_delta_time = 0.0; uint64_t frame_counter = 0; + bool draw_imgui_demo = false; + while(!glfwWindowShouldClose(gWindow)) { frame_counter++; @@ -157,7 +159,7 @@ int main(void) glfwGetWindowSize(gWindow, &width, &height); glfwPollEvents(); -// ImGui_ImplGlfwGL3_NewFrame(); + ImGui_ImplGlfwGL3_NewFrame(); // imguiBeginFrame (gGuiInputState->mouseX, // gGuiInputState->mouseY, @@ -188,45 +190,60 @@ int main(void) assert (gTimer->mDeltaTime >= 0.0f); int width, height; glfwGetWindowSize(gWindow, &width, &height); -//#ifdef USE_DOCKS -// ImGui::SetNextWindowPos(ImVec2(0.0f, 20.0f)); -// ImGui::SetNextWindowSize(ImVec2(width, height)); -// if (ImGui::Begin("DockArea", NULL, -// ImGuiWindowFlags_NoTitleBar -// | ImGuiWindowFlags_NoResize -// | ImGuiWindowFlags_NoMove -// | ImGuiWindowFlags_NoBringToFrontOnFocus -// )) { -// ImGui::BeginDockspace(); -// -// if (ImGui::BeginDock("dock1")) { -// ImGui::Text("HEllo 1"); -// } -// ImGui::EndDock(); -// -// if (ImGui::BeginDock("dock2")) { -// ImGui::Text("HEllo2"); -// } -// ImGui::EndDock(); -// -// if (ImGui::BeginDock("dock3")) { -// ImGui::Text("HEllo3"); -// } -// ImGui::EndDock(); -// -// -//#endif + + + ImGui::BeginMainMenuBar(); + + if (ImGui::BeginMenu("Dialogs")) + { + ImGui::Checkbox("ImGui Demo", &draw_imgui_demo); + ImGui::EndMenu(); + } + + ImGui::EndMainMenuBar(); + + if (draw_imgui_demo) + ImGui::ShowDemoWindow(); + +#ifdef USE_DOCKS + ImGui::SetNextWindowPos(ImVec2(0.0f, 10.0f)); + ImGui::SetNextWindowSize(ImVec2(width, height)); + if (ImGui::Begin("DockArea", NULL, + ImGuiWindowFlags_NoTitleBar + | ImGuiWindowFlags_NoResize + | ImGuiWindowFlags_NoMove + | ImGuiWindowFlags_NoBringToFrontOnFocus + )) { + ImGui::BeginDockspace(); + + if (ImGui::BeginDock("dock1")) { + ImGui::Text("HEllo 1"); + } + ImGui::EndDock(); + + if (ImGui::BeginDock("dock2")) { + ImGui::Text("HEllo2"); + } + ImGui::EndDock(); + + if (ImGui::BeginDock("dock3")) { + ImGui::Text("HEllo3"); + } + ImGui::EndDock(); + + +#endif module_manager.Update(gTimer->mDeltaTime); -// #ifdef USE_DOCKS -// ImGui::EndDockspace(); -// } + #ifdef USE_DOCKS + ImGui::EndDockspace(); + } + + ImGui::End(); + #endif // -// ImGui::End(); -// #endif -// -// ImGui::Render(); + ImGui::Render(); usleep(16000); diff --git a/src/modules/RenderModule.cc b/src/modules/RenderModule.cc index 33d670b..27b29d2 100644 --- a/src/modules/RenderModule.cc +++ b/src/modules/RenderModule.cc @@ -3,12 +3,15 @@ #include "RenderModule.h" #include +#include "imgui/imgui.h" +#include "imgui_dock.h" + using namespace SimpleMath::GL; struct Renderer; static const GLfloat g_vertex_buffer_data[] = { - -0.7f, -0.9f, 0.0f, + -0.9f, -0.9f, 0.0f, 0.9f, -0.9f, 0.0f, 0.0f, 0.9f, 1.0f }; @@ -228,16 +231,37 @@ void Renderer::RenderGl() { glDrawArrays(GL_TRIANGLES, 0, 3); // starting from vertex 0; 3 vertices total glDisableVertexAttribArray(0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); } void Renderer::RenderGui() { + bool render_color = true; + + GLuint texture; + if (render_color) { + texture = mRenderTarget.mColorTexture; + } else { + texture = mRenderTarget.mDepthTexture; + } + + if (ImGui::BeginDock("Scene")) { + ImGui::Text("Scene"); + const ImVec2 content_avail = ImGui::GetContentRegionAvail(); + ImGui::Image((void*) texture, + content_avail, + ImVec2(0.0f, 1.0f), + ImVec2(1.0f, 0.0f) + ); + } + ImGui::EndDock(); + + return; + glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glActiveTexture(GL_TEXTURE0); - bool render_color = false; - Matrix44f model_view_projection = Matrix44f::Identity(); if (render_color) {