Fix issues with ui rendering
This commit is contained in:
@@ -20,6 +20,8 @@ namespace openVulkanoCpp::Vulkan
|
||||
frameBuffer->RegisterRenderPass(this);
|
||||
m_beginInfo.renderPass = renderPass;
|
||||
m_beginInfo.renderArea = vk::Rect2D(vk::Offset2D(), m_frameBuffer->GetSize2D());
|
||||
m_beginInfo.clearValueCount = 2;
|
||||
m_beginInfo.pClearValues = m_clearValues.data();
|
||||
if (clearColor) SetClearColor(EngineConfiguration::GetEngineConfiguration()->GetFrameBufferClearColor());
|
||||
if (clearDepth) SetClearDepth();
|
||||
}
|
||||
@@ -30,18 +32,6 @@ namespace openVulkanoCpp::Vulkan
|
||||
m_frameBuffer = nullptr;
|
||||
}
|
||||
|
||||
void RenderPass::UpdateBeginInfo()
|
||||
{
|
||||
uint32_t size = 0;
|
||||
vk::ClearValue* clearValues = nullptr;
|
||||
if (m_useClearColor) { size++; clearValues = m_clearValues.data(); }
|
||||
else if (m_useClearDepth) clearValues = &m_clearValues[1];
|
||||
if (m_useClearColor && m_useClearDepth) size++;
|
||||
|
||||
m_beginInfo.clearValueCount = size;
|
||||
m_beginInfo.pClearValues = clearValues;
|
||||
}
|
||||
|
||||
void RenderPass::Begin(vk::CommandBuffer& commandBuffer, bool primaryBuffer)
|
||||
{
|
||||
m_beginInfo.framebuffer = m_frameBuffer->GetCurrentFrameBuffer();
|
||||
|
||||
@@ -39,43 +39,23 @@ namespace openVulkanoCpp::Vulkan
|
||||
void SetClearColor(vk::ClearColorValue clearColor = vk::ClearColorValue(std::array<float, 4>{ 0.39f, 0.58f, 0.93f, 1.0f }))
|
||||
{
|
||||
m_clearValues[0] = clearColor;
|
||||
if (!m_useClearColor)
|
||||
{
|
||||
m_useClearColor = true;
|
||||
//TODO recreate
|
||||
}
|
||||
UpdateBeginInfo();
|
||||
if (!m_useClearColor) m_useClearColor = true;
|
||||
}
|
||||
|
||||
void DisableClearColor()
|
||||
{
|
||||
if (m_useClearColor)
|
||||
{
|
||||
m_useClearColor = false;
|
||||
//TODO recreate
|
||||
UpdateBeginInfo();
|
||||
}
|
||||
if (m_useClearColor) m_useClearColor = false;
|
||||
}
|
||||
|
||||
void SetClearDepth(vk::ClearDepthStencilValue clearDepth = vk::ClearDepthStencilValue(1, 0))
|
||||
{
|
||||
m_clearValues[1] = clearDepth;
|
||||
if (!m_useClearDepth)
|
||||
{
|
||||
m_useClearDepth = true;
|
||||
//TODO recreate
|
||||
}
|
||||
UpdateBeginInfo();
|
||||
if (!m_useClearDepth) m_useClearDepth = true;
|
||||
}
|
||||
|
||||
void DisableClearDepth()
|
||||
{
|
||||
if (m_useClearDepth)
|
||||
{
|
||||
m_useClearDepth = false;
|
||||
//TODO recreate
|
||||
UpdateBeginInfo();
|
||||
}
|
||||
if (m_useClearDepth) m_useClearDepth = false;
|
||||
}
|
||||
|
||||
void Resize(vk::Extent3D size)
|
||||
@@ -84,8 +64,6 @@ namespace openVulkanoCpp::Vulkan
|
||||
m_beginInfo.renderArea.extent.height = size.height;
|
||||
}
|
||||
|
||||
virtual void UpdateBeginInfo();
|
||||
|
||||
virtual void Begin(vk::CommandBuffer& commandBuffer, bool primaryBuffer = false);
|
||||
|
||||
virtual void End(vk::CommandBuffer& commandBuffer);
|
||||
|
||||
@@ -74,6 +74,7 @@ namespace openVulkanoCpp::Vulkan
|
||||
{
|
||||
resourceManager.Close();
|
||||
context.Close();
|
||||
uiRenderer.Close();
|
||||
}
|
||||
|
||||
std::string Renderer::GetMainRenderDeviceName()
|
||||
|
||||
@@ -61,10 +61,11 @@ namespace openVulkanoCpp::Vulkan
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
|
||||
ImGui_ImplVulkan_Init(&vkInfo, uiRenderPass.renderPass);
|
||||
window = context->window;
|
||||
#ifdef GLFW_AVAILABLE
|
||||
ImGui_ImplGlfw_InitForVulkan((GLFWwindow*)context->window->GetNativeWindowHandle(), true);
|
||||
ImGui_ImplGlfw_InitForVulkan((GLFWwindow*)window->GetNativeWindowHandle(), true);
|
||||
#else
|
||||
ImGuiImplOpenVulkano::INSTANCE.Init(context->window);
|
||||
ImGuiImplOpenVulkano::INSTANCE.Init(window);
|
||||
#endif
|
||||
|
||||
uiInitialized = true;
|
||||
@@ -75,7 +76,10 @@ namespace openVulkanoCpp::Vulkan
|
||||
{
|
||||
uiInitialized = false;
|
||||
#ifdef GLFW_AVAILABLE
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
if (!window->WindowHasBeenDestroyed())
|
||||
{
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
}
|
||||
#else
|
||||
ImGuiImplOpenVulkano::INSTANCE.Close();
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "RenderPass.hpp"
|
||||
#include "Base/UI/IWindow.hpp"
|
||||
#include "Scene/UI/UI.hpp"
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
@@ -20,6 +21,7 @@ namespace openVulkanoCpp::Vulkan
|
||||
RenderPass uiRenderPass;
|
||||
vk::DescriptorPool descriptorPool;
|
||||
Scene::UI::Ui* ui;
|
||||
IWindow* window = nullptr;
|
||||
bool uiInitialized = false;
|
||||
|
||||
public:
|
||||
@@ -27,7 +29,7 @@ namespace openVulkanoCpp::Vulkan
|
||||
|
||||
UiRenderer(Context* context) { Init(context); }
|
||||
|
||||
~UiRenderer() { if (descriptorPool) Close(); }
|
||||
~UiRenderer() { if (uiInitialized) Close(); }
|
||||
|
||||
void Init(Context* context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user