Add imgui rendering ability on none glfw windows

This commit is contained in:
2023-09-07 00:54:22 +02:00
parent 9709861bda
commit 2bcea0d7fd
3 changed files with 106 additions and 0 deletions

View File

@@ -12,6 +12,8 @@
#if __has_include("GLFW/glfw3.h")
#include <imgui_impl_glfw.h>
#define GLFW_AVAILABLE
#else
#include "Host/ImGuiImplOpenVulkano.hpp"
#endif
namespace openVulkanoCpp::Vulkan
@@ -61,6 +63,8 @@ namespace openVulkanoCpp::Vulkan
ImGui_ImplVulkan_Init(&vkInfo, uiRenderPass.renderPass);
#ifdef GLFW_AVAILABLE
ImGui_ImplGlfw_InitForVulkan((GLFWwindow*)context->window->GetNativeWindowHandle(), true);
#else
ImGuiImplOpenVulkano::INSTANCE.Init(context->window);
#endif
uiInitialized = true;
@@ -70,6 +74,11 @@ namespace openVulkanoCpp::Vulkan
void UiRenderer::Close()
{
uiInitialized = false;
#ifdef GLFW_AVAILABLE
ImGui_ImplGlfw_Shutdown();
#else
ImGuiImplOpenVulkano::INSTANCE.Close();
#endif
ImGui_ImplVulkan_Shutdown();
device.destroy(descriptorPool);
}
@@ -79,6 +88,8 @@ namespace openVulkanoCpp::Vulkan
ImGui_ImplVulkan_NewFrame();
#ifdef GLFW_AVAILABLE
ImGui_ImplGlfw_NewFrame();
#else
ImGuiImplOpenVulkano::INSTANCE.NewFrame();
#endif
ImGui::NewFrame();
}