diff --git a/3rdParty/imgui/CMakeLists.txt b/3rdParty/imgui/CMakeLists.txt index bfbcc74..2a6d4c0 100644 --- a/3rdParty/imgui/CMakeLists.txt +++ b/3rdParty/imgui/CMakeLists.txt @@ -7,7 +7,7 @@ set(IMGUI_SRC_DIR ${CMAKE_BINARY_DIR}/3rdParty/imgui/imgui-src) FetchContent_Populate(imgui GIT_REPOSITORY https://github.com/ocornut/imgui.git GIT_SHALLOW TRUE - GIT_TAG v1.89.8-docking + GIT_TAG v1.90-docking SOURCE_DIR ${IMGUI_SRC_DIR} ) diff --git a/openVulkanoCpp/Scene/UI/UI.hpp b/openVulkanoCpp/Scene/UI/UI.hpp index 8888728..c8349c0 100644 --- a/openVulkanoCpp/Scene/UI/UI.hpp +++ b/openVulkanoCpp/Scene/UI/UI.hpp @@ -17,25 +17,34 @@ namespace openVulkanoCpp::Scene::UI public: std::vector> children; - virtual ~UiElement() override = default; + ~UiElement() override = default; - virtual void Tick() override {}; + void Tick() override {}; - virtual void Draw() const; - - void Render() const + void Render() { + BeginDraw(); Draw(); for(const auto& child : children) { child->Render(); } + EndDraw(); } + + protected: + virtual void BeginDraw() {}; + + virtual void Draw() = 0; + + virtual void EndDraw() {}; }; class Ui : public UiElement { public: - void Draw() const override {} + virtual void Init() = 0; + + void Draw() override {} }; } diff --git a/openVulkanoCpp/Vulkan/RenderPass.cpp b/openVulkanoCpp/Vulkan/RenderPass.cpp index 1c23f59..38e64ac 100644 --- a/openVulkanoCpp/Vulkan/RenderPass.cpp +++ b/openVulkanoCpp/Vulkan/RenderPass.cpp @@ -36,7 +36,7 @@ namespace openVulkanoCpp::Vulkan vk::ClearValue* clearValues = nullptr; if (m_useClearColor) { size++; clearValues = m_clearValues.data(); } else if (m_useClearDepth) clearValues = &m_clearValues[1]; - if (m_useClearDepth) size++; + if (m_useClearColor && m_useClearDepth) size++; m_beginInfo.clearValueCount = size; m_beginInfo.pClearValues = clearValues; diff --git a/openVulkanoCpp/Vulkan/UiRenderer.cpp b/openVulkanoCpp/Vulkan/UiRenderer.cpp index 8bd8ef9..b6384ca 100644 --- a/openVulkanoCpp/Vulkan/UiRenderer.cpp +++ b/openVulkanoCpp/Vulkan/UiRenderer.cpp @@ -62,10 +62,14 @@ namespace openVulkanoCpp::Vulkan #ifdef GLFW_AVAILABLE ImGui_ImplGlfw_InitForVulkan((GLFWwindow*)context->window->GetNativeWindowHandle(), true); #endif + + uiInitialized = true; + if (ui) ui->Init(); } void UiRenderer::Close() { + uiInitialized = false; ImGui_ImplVulkan_Shutdown(); device.destroy(descriptorPool); } @@ -91,4 +95,10 @@ namespace openVulkanoCpp::Vulkan ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmdBuffer); uiRenderPass.End(cmdBuffer); } + + void UiRenderer::SetActiveUi(Scene::UI::Ui* ui) + { + this->ui = ui; + if (ui && uiInitialized) ui->Init(); + } } diff --git a/openVulkanoCpp/Vulkan/UiRenderer.hpp b/openVulkanoCpp/Vulkan/UiRenderer.hpp index 2eee555..1fcbcda 100644 --- a/openVulkanoCpp/Vulkan/UiRenderer.hpp +++ b/openVulkanoCpp/Vulkan/UiRenderer.hpp @@ -20,6 +20,7 @@ namespace openVulkanoCpp::Vulkan RenderPass uiRenderPass; vk::DescriptorPool descriptorPool; Scene::UI::Ui* ui; + bool uiInitialized = false; public: UiRenderer() = default; @@ -36,7 +37,7 @@ namespace openVulkanoCpp::Vulkan void Close(); - void SetActiveUi(Scene::UI::Ui* ui) { this->ui = ui; } + void SetActiveUi(Scene::UI::Ui* ui); Scene::UI::Ui* GetActiveUi() { return ui; } };