Added SHWindow to SHImguiWindow
This commit is contained in:
parent
4ccfd399af
commit
fdc8a61c1d
|
@ -137,7 +137,7 @@ namespace SHADE
|
||||||
std::array<float, 2> translate;
|
std::array<float, 2> translate;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SHImGuiVulkanBackend::CreateInstance(Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkRenderpass> const& renderpass, uint32_t subpassIndex) noexcept
|
void SHImGuiVulkanBackend::CreateInstance(Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkRenderpass> const& renderpass, uint32_t subpassIndex, SHWindow& mainWindow) noexcept
|
||||||
{
|
{
|
||||||
if (ImGui::GetCurrentContext() == nullptr)
|
if (ImGui::GetCurrentContext() == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -189,6 +189,7 @@ namespace SHADE
|
||||||
|
|
||||||
//Initialize instance
|
//Initialize instance
|
||||||
auto instance = std::make_unique<SHBreachInstance>();
|
auto instance = std::make_unique<SHBreachInstance>();
|
||||||
|
instance->window = mainWindow;
|
||||||
instance->InitializePipeline(io, renderpass, subpassIndex);
|
instance->InitializePipeline(io, renderpass, subpassIndex);
|
||||||
instance->lastFrameTime = std::chrono::high_resolution_clock::now();
|
instance->lastFrameTime = std::chrono::high_resolution_clock::now();
|
||||||
io.UserData = instance.release();
|
io.UserData = instance.release();
|
||||||
|
@ -200,9 +201,10 @@ namespace SHADE
|
||||||
|
|
||||||
void SHImGuiVulkanBackend::Render(void) noexcept
|
void SHImGuiVulkanBackend::Render(void) noexcept
|
||||||
{
|
{
|
||||||
|
GETINSTANCE
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImDrawData* drawData = ImGui::GetDrawData();
|
ImDrawData* drawData = ImGui::GetDrawData();
|
||||||
//TODO: instance draw data
|
//instance.Render(io, drawData, )
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHImGuiVulkanBackend::CreateChildWindow(ImGuiViewport* viewport) noexcept
|
void SHImGuiVulkanBackend::CreateChildWindow(ImGuiViewport* viewport) noexcept
|
||||||
|
@ -210,6 +212,7 @@ namespace SHADE
|
||||||
GETINSTANCE
|
GETINSTANCE
|
||||||
|
|
||||||
auto& info = *new SHImGuiWindow{ instance.device };
|
auto& info = *new SHImGuiWindow{ instance.device };
|
||||||
|
info.window.Create({}, instance.window.GetHWND());
|
||||||
viewport->RendererUserData = &info;
|
viewport->RendererUserData = &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +220,9 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
GETINSTANCE
|
GETINSTANCE
|
||||||
|
|
||||||
auto info = reinterpret_cast<SHImGuiWindow*>(viewport->RendererUserData);
|
auto info = reinterpret_cast<SHImGuiWindow*>(viewport->RendererUserData);
|
||||||
|
info->window.Close();
|
||||||
|
info->window.Destroy();
|
||||||
delete info;
|
delete info;
|
||||||
viewport->RendererUserData = nullptr;
|
viewport->RendererUserData = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -230,20 +235,37 @@ namespace SHADE
|
||||||
|
|
||||||
void SHImGuiVulkanBackend::SetChildWindowSize(ImGuiViewport* viewport, ImVec2 size) noexcept
|
void SHImGuiVulkanBackend::SetChildWindowSize(ImGuiViewport* viewport, ImVec2 size) noexcept
|
||||||
{
|
{
|
||||||
|
auto& info = *reinterpret_cast<SHImGuiWindow*>(viewport->RendererUserData);
|
||||||
|
SetWindowPos
|
||||||
|
(
|
||||||
|
info.window.GetHWND(),
|
||||||
|
HWND_TOPMOST,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
static_cast<int>(size.x),
|
||||||
|
static_cast<int>(size.y),
|
||||||
|
SWP_NOMOVE | SWP_NOZORDER
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 SHImGuiVulkanBackend::GetChildWindowPos(ImGuiViewport* viewport) noexcept
|
ImVec2 SHImGuiVulkanBackend::GetChildWindowPos(ImGuiViewport* viewport) noexcept
|
||||||
{
|
{
|
||||||
return {};
|
auto& info = *reinterpret_cast<SHImGuiWindow*>(viewport->RendererUserData);
|
||||||
|
auto [x, y] = info.window.GetWindowSize();
|
||||||
|
return {static_cast<float>(x), static_cast<float>(y)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHImGuiVulkanBackend::SetChildWindowPos(ImGuiViewport* viewport, ImVec2 size) noexcept
|
void SHImGuiVulkanBackend::SetChildWindowPos(ImGuiViewport* viewport, ImVec2 size) noexcept
|
||||||
{
|
{
|
||||||
|
auto& info = *reinterpret_cast<SHImGuiWindow*>(viewport->RendererUserData);
|
||||||
|
info.window.SetPosition(size.x, size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHImGuiVulkanBackend::RenderChildWindow(ImGuiViewport* viewport, void*) noexcept
|
void SHImGuiVulkanBackend::RenderChildWindow(ImGuiViewport* viewport, void*) noexcept
|
||||||
{
|
{
|
||||||
|
GETINSTANCE;
|
||||||
|
auto& info = *reinterpret_cast<SHImGuiWindow*>(viewport->RendererUserData);
|
||||||
|
//info.Render(io, viewport->DrawData, instance);;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHImGuiVulkanBackend::ChildSwapBuffers(ImGuiViewport* viewport, void*) noexcept
|
void SHImGuiVulkanBackend::ChildSwapBuffers(ImGuiViewport* viewport, void*) noexcept
|
||||||
|
@ -272,6 +294,11 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHImGuiVulkanBackend::SHImGuiWindow::Render(ImGuiIO& io, ImDrawData* drawData,
|
||||||
|
Handle<SHVkDescriptorSetGroup> descriptorSetGroup)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHImGuiVulkanBackend::SHBreachInstance::CreateFontsTexture(Handle<SHVkImage> image, ImGuiIO& io) noexcept
|
void SHImGuiVulkanBackend::SHBreachInstance::CreateFontsTexture(Handle<SHVkImage> image, ImGuiIO& io) noexcept
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <Graphics/Instance/SHVkInstance.h>
|
#include "Graphics/Instance/SHVkInstance.h"
|
||||||
#include "Graphics/Buffers/SHVkBuffer.h"
|
#include "Graphics/Buffers/SHVkBuffer.h"
|
||||||
#include "Graphics/Images/SHVkImage.h"
|
#include "Graphics/Images/SHVkImage.h"
|
||||||
#include <Graphics/Devices/SHVkPhysicalDevice.h>
|
#include "Graphics/Devices/SHVkPhysicalDevice.h"
|
||||||
#include <Graphics/Devices/SHVkLogicalDevice.h>
|
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
||||||
#include <Graphics/Pipeline/SHVkPipeline.h>
|
#include "Graphics/Pipeline/SHVkPipeline.h"
|
||||||
#include "Graphics/Swapchain/SHVkSwapchain.h"
|
#include "Graphics/Swapchain/SHVkSwapchain.h"
|
||||||
#include <Graphics/MiddleEnd/Interface/SHGraphicsSystem.h>
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||||
#include "Graphics/Debugging/SHVulkanDebugUtil.h"
|
#include "Graphics/Debugging/SHVulkanDebugUtil.h"
|
||||||
|
#include "Graphics/Windowing/SHWindow.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -21,15 +22,14 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
Handle<SHVkBuffer> vertexBuffer;
|
Handle<SHVkBuffer> vertexBuffer;
|
||||||
Handle<SHVkBuffer> indicesBuffer;
|
Handle<SHVkBuffer> indicesBuffer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Handle<SHVkLogicalDevice> device;
|
Handle<SHVkLogicalDevice> device;
|
||||||
|
SHWindow window;
|
||||||
std::array<Buffers, 2> primitiveBuffers;
|
std::array<Buffers, 2> primitiveBuffers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void InitializeBuffers(void) noexcept;
|
void InitializeBuffers(void) noexcept;
|
||||||
|
void Render(ImGuiIO& io, ImDrawData* drawData, Handle<SHVkDescriptorSetGroup> descriptorSetGroup);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SHBreachInstance : public SHImGuiWindow
|
struct SHBreachInstance : public SHImGuiWindow
|
||||||
|
@ -44,7 +44,7 @@ namespace SHADE
|
||||||
void InitializePipeline(ImGuiIO& io, Handle<SHVkRenderpass> const& renderpass, uint32_t subpassIndex) noexcept;
|
void InitializePipeline(ImGuiIO& io, Handle<SHVkRenderpass> const& renderpass, uint32_t subpassIndex) noexcept;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
static void CreateInstance(Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkRenderpass> const& renderpass, uint32_t subpassIndex) noexcept;
|
static void CreateInstance(Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkRenderpass> const& renderpass, uint32_t subpassIndex, SHWindow& mainWindow) noexcept;
|
||||||
static void Render(void) noexcept;
|
static void Render(void) noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ namespace SHADE
|
||||||
return true;
|
return true;
|
||||||
{
|
{
|
||||||
MSG Message;
|
MSG Message;
|
||||||
while (PeekMessageW(&Message, NULL, 0, 0, PM_REMOVE))
|
while (PeekMessageW(&Message, wndHWND, 0, 0, PM_REMOVE))
|
||||||
{
|
{
|
||||||
if (WM_QUIT == Message.message)
|
if (WM_QUIT == Message.message)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue