[WIP] Editor: ImGui-Vulkan integration
This commit is contained in:
parent
4eb7e1f5f4
commit
a8d00a29ec
|
@ -2,9 +2,10 @@
|
|||
#include "SBApplication.h"
|
||||
#include "Engine/ECS_Base/System/SHSystemManager.h"
|
||||
|
||||
#define SHEDITOR
|
||||
#ifdef SHEDITOR
|
||||
#include "Editor/SHEditor.h"
|
||||
#include "Scenes/SBEditorScene.h"
|
||||
//#include "Scenes/SBEditorScene.h"
|
||||
#endif // SHEDITOR
|
||||
|
||||
#include <chrono>
|
||||
|
@ -29,8 +30,8 @@ namespace Sandbox
|
|||
graphicsSystem->SetWindow(&window);
|
||||
|
||||
SHADE::SHSystemManager::Init();
|
||||
|
||||
#ifdef SHEDITOR
|
||||
SHADE::SHEditor::Initialize(window.GetHWND());
|
||||
#else
|
||||
#endif
|
||||
|
||||
|
@ -43,9 +44,14 @@ namespace Sandbox
|
|||
//TODO: Change true to window is open
|
||||
while (!window.WindowShouldClose())
|
||||
{
|
||||
#ifdef SHEDITOR
|
||||
//SHADE::SHEditor::PreRender();
|
||||
#endif
|
||||
graphicsSystem->BeginRender();
|
||||
#ifdef SHEDITOR
|
||||
#else
|
||||
SHADE::SHEditor::PreRender();
|
||||
SHADE::SHEditor::Update();
|
||||
SHADE::SHEditor::Render();
|
||||
#endif
|
||||
graphicsSystem->EndRender();
|
||||
}
|
||||
|
@ -54,6 +60,7 @@ namespace Sandbox
|
|||
|
||||
void SBApplication::Exit(void)
|
||||
{
|
||||
//SHADE::SHEditor::Exit();
|
||||
SHADE::SHSystemManager::Exit();
|
||||
|
||||
#ifdef SHEDITOR
|
||||
|
|
|
@ -102,6 +102,8 @@
|
|||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Editor\SHEditor.h" />
|
||||
<ClInclude Include="src\Editor\SHEditorBackend.h" />
|
||||
<ClInclude Include="src\Engine\ECS_Base\Components\SHComponent.h" />
|
||||
<ClInclude Include="src\Engine\ECS_Base\Components\SHComponentGroup.h" />
|
||||
<ClInclude Include="src\Engine\ECS_Base\Entity\SHEntity.h" />
|
||||
|
@ -186,6 +188,7 @@
|
|||
<ClInclude Include="src\Tools\SHLogger.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Editor\SHEditor.cpp" />
|
||||
<ClCompile Include="src\Engine\ECS_Base\Components\SHComponent.cpp" />
|
||||
<ClCompile Include="src\Engine\ECS_Base\Components\SHComponentGroup.cpp" />
|
||||
<ClCompile Include="src\Engine\ECS_Base\Entity\SHEntity.cpp" />
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Editor">
|
||||
<UniqueIdentifier>{8C1A20B0-78BC-4A86-6177-5EDA4DB8D1D6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Engine">
|
||||
<UniqueIdentifier>{DBC7D3B0-C769-FE86-B024-12DB9C6585D7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -108,6 +111,12 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Editor\SHEditor.h">
|
||||
<Filter>Editor</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Editor\SHEditorBackend.h">
|
||||
<Filter>Editor</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Engine\ECS_Base\Components\SHComponent.h">
|
||||
<Filter>Engine\ECS_Base\Components</Filter>
|
||||
</ClInclude>
|
||||
|
@ -354,6 +363,9 @@
|
|||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Editor\SHEditor.cpp">
|
||||
<Filter>Editor</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Engine\ECS_Base\Components\SHComponent.cpp">
|
||||
<Filter>Engine\ECS_Base\Components</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
@ -2,16 +2,41 @@
|
|||
#include "SHEditor.h"
|
||||
#include "SHEditorBackend.h"
|
||||
|
||||
#include <Engine/ECS_Base/System/SHSystemManager.h>
|
||||
#include <Graphics/Instance/SHVkInstance.h>
|
||||
|
||||
#include <Graphics/MiddleEnd/Interface/SHGraphicsSystem.h>
|
||||
#include <Graphics/Devices/SHVkPhysicalDevice.h>
|
||||
#include <Graphics/Devices/SHVkLogicalDevice.h>
|
||||
#include "Graphics/Swapchain/SHVkSwapchain.h"
|
||||
#include "Graphics/Debugging/SHVulkanDebugUtil.h"
|
||||
|
||||
#include "Tools/SHLogger.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
void SHEditor::Initialize()
|
||||
Handle<SHVkCommandPool> SHEditor::cmdPool;
|
||||
Handle<SHVkCommandBuffer> SHEditor::cmdBuffer;
|
||||
|
||||
void SHEditor::Initialize(HWND hwnd)
|
||||
{
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
|
||||
SetupWin32Backend();
|
||||
SetupWin32Backend(hwnd);
|
||||
SetupVulkanBackend();
|
||||
|
||||
//ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
|
||||
}
|
||||
|
||||
void SHEditor::PreRender()
|
||||
{
|
||||
cmdPool->Reset();
|
||||
}
|
||||
|
||||
void SHEditor::Update()
|
||||
|
@ -19,13 +44,21 @@ namespace SHADE
|
|||
NewFrame();
|
||||
|
||||
//Add all windows to draw list, Perform necessary updates
|
||||
ImGui::ShowDemoWindow();
|
||||
|
||||
ImGui::Render();
|
||||
}
|
||||
|
||||
void SHEditor::Render()
|
||||
{
|
||||
//ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), )
|
||||
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmdBuffer->GetVkCommandBuffer());
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
{
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
}
|
||||
}
|
||||
|
||||
void SHEditor::Exit()
|
||||
|
@ -38,8 +71,31 @@ namespace SHADE
|
|||
void SHEditor::SetupVulkanBackend()
|
||||
{
|
||||
ImGui_ImplVulkan_InitInfo initInfo;
|
||||
//initInfo.Device =
|
||||
ImGui_ImplVulkan_Init(&initInfo, VK_NULL_HANDLE);
|
||||
|
||||
initInfo.Instance = SHVkInstance::GetVkInstance();
|
||||
auto gfxSystem = reinterpret_cast<SHGraphicsSystem*>(SHSystemManager::GetSystem("Graphics System"));
|
||||
initInfo.PhysicalDevice = gfxSystem->GetPhysicalDevice()->GetVkPhysicalDevice();
|
||||
initInfo.Device = gfxSystem->GetDevice()->GetVkLogicalDevice();
|
||||
initInfo.Queue = gfxSystem->GetQueue()->GetVkQueue();
|
||||
initInfo.MinImageCount = initInfo.ImageCount = gfxSystem->GetSwapchain()->GetNumImages();
|
||||
initInfo.DescriptorPool = gfxSystem->GetDescriptorPool()->GetVkHandle();
|
||||
initInfo.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||
initInfo.Allocator = nullptr;
|
||||
initInfo.PipelineCache = nullptr;
|
||||
initInfo.Subpass = 0;
|
||||
initInfo.CheckVkResultFn = [](VkResult err)
|
||||
{
|
||||
if (err == VK_SUCCESS)
|
||||
return;
|
||||
SHVulkanDebugUtil::ReportVkError(vk::Result(err), "Editor Error");
|
||||
};
|
||||
|
||||
ImGui_ImplVulkan_Init(&initInfo, gfxSystem->GetRenderGraph().GetNode("G-Buffer")->GetRenderpass()->GetVkRenderpass());
|
||||
|
||||
cmdPool = gfxSystem->GetDevice()->CreateCommandPool(SH_QUEUE_FAMILY_ARRAY_INDEX::GRAPHICS, SH_CMD_POOL_RESET::POOL_BASED, true);
|
||||
cmdBuffer = cmdPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
||||
|
||||
ImGui_ImplVulkan_CreateFontsTexture(cmdBuffer->GetVkCommandBuffer());
|
||||
}
|
||||
|
||||
void SHEditor::ShutdownVulkanBackend()
|
||||
|
@ -49,11 +105,14 @@ namespace SHADE
|
|||
|
||||
void SHEditor::NewFrame()
|
||||
{
|
||||
ImGui_ImplWin32_NewFrame();
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
void SHEditor::SetupWin32Backend()
|
||||
void SHEditor::SetupWin32Backend(HWND hwnd)
|
||||
{
|
||||
//ImGui_ImplWin32_Init(/*hwnd*/);
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
}
|
||||
|
||||
void SHEditor::ShutdownWin32Backend()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include "Graphics/Commands/SHVkCommandPool.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -6,7 +7,9 @@ namespace SHADE
|
|||
{
|
||||
public:
|
||||
|
||||
static void Initialize();
|
||||
static void Initialize(HWND hwnd);
|
||||
|
||||
static void PreRender();
|
||||
|
||||
static void Update();
|
||||
|
||||
|
@ -15,11 +18,14 @@ namespace SHADE
|
|||
static void Exit();
|
||||
|
||||
private:
|
||||
static void SetupWin32Backend();
|
||||
static void SetupWin32Backend(HWND hwnd);
|
||||
static void ShutdownWin32Backend();
|
||||
static void SetupVulkanBackend();
|
||||
static void ShutdownVulkanBackend();
|
||||
|
||||
static void NewFrame();
|
||||
|
||||
static Handle<SHVkCommandPool> cmdPool;
|
||||
static Handle<SHVkCommandBuffer> cmdBuffer;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue