feat: update editor ui framework and assets
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <dxgi1_6.h>
|
||||
#include <array>
|
||||
#include <windows.h>
|
||||
|
||||
namespace XCEngine {
|
||||
@@ -12,6 +13,8 @@ namespace Platform {
|
||||
|
||||
class D3D12WindowRenderer {
|
||||
public:
|
||||
static constexpr UINT kSrvDescriptorCount = 64;
|
||||
|
||||
bool Initialize(HWND hwnd, int width, int height) {
|
||||
m_hwnd = hwnd;
|
||||
m_width = width;
|
||||
@@ -36,7 +39,9 @@ public:
|
||||
m_height = 720;
|
||||
m_fenceValue = 0;
|
||||
m_rtvDescriptorSize = 0;
|
||||
m_srvDescriptorSize = 0;
|
||||
m_frameIndex = 0;
|
||||
m_srvDescriptorUsage.fill(false);
|
||||
}
|
||||
|
||||
void Resize(int width, int height) {
|
||||
@@ -107,6 +112,18 @@ public:
|
||||
return m_srvHeap;
|
||||
}
|
||||
|
||||
ID3D12CommandQueue* GetCommandQueue() const {
|
||||
return m_commandQueue;
|
||||
}
|
||||
|
||||
UINT GetSrvDescriptorSize() const {
|
||||
return m_srvDescriptorSize;
|
||||
}
|
||||
|
||||
UINT GetSrvDescriptorCount() const {
|
||||
return kSrvDescriptorCount;
|
||||
}
|
||||
|
||||
private:
|
||||
bool CreateDevice() {
|
||||
HRESULT hr = D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device));
|
||||
@@ -164,10 +181,12 @@ private:
|
||||
|
||||
D3D12_DESCRIPTOR_HEAP_DESC srvDesc = {};
|
||||
srvDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
|
||||
srvDesc.NumDescriptors = 1;
|
||||
srvDesc.NumDescriptors = kSrvDescriptorCount;
|
||||
srvDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
|
||||
hr = m_device->CreateDescriptorHeap(&srvDesc, IID_PPV_ARGS(&m_srvHeap));
|
||||
if (FAILED(hr)) return false;
|
||||
m_srvDescriptorSize = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
m_srvDescriptorUsage.fill(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -210,7 +229,9 @@ private:
|
||||
ID3D12Fence* m_fence = nullptr;
|
||||
UINT64 m_fenceValue = 0;
|
||||
UINT m_rtvDescriptorSize = 0;
|
||||
UINT m_srvDescriptorSize = 0;
|
||||
UINT m_frameIndex = 0;
|
||||
std::array<bool, kSrvDescriptorCount> m_srvDescriptorUsage = {};
|
||||
};
|
||||
|
||||
} // namespace Platform
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Application.h"
|
||||
#include "EditorResources.h"
|
||||
#include "UI/ImGuiBackendBridge.h"
|
||||
|
||||
#include <windows.h>
|
||||
@@ -18,8 +19,22 @@ inline LRESULT WINAPI EditorWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
|
||||
case WM_SIZE:
|
||||
if (wParam != SIZE_MINIMIZED) {
|
||||
Application::Get().OnResize(static_cast<int>(LOWORD(lParam)), static_cast<int>(HIWORD(lParam)));
|
||||
if (Application::Get().IsRenderReady()) {
|
||||
Application::Get().Render();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case WM_PAINT:
|
||||
if (Application::Get().IsRenderReady()) {
|
||||
PAINTSTRUCT ps = {};
|
||||
BeginPaint(hWnd, &ps);
|
||||
Application::Get().Render();
|
||||
EndPaint(hWnd, &ps);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
case WM_SYSCOMMAND:
|
||||
if ((wParam & 0xfff0) == SC_KEYMENU) {
|
||||
return 0;
|
||||
@@ -34,11 +49,21 @@ inline LRESULT WINAPI EditorWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
|
||||
}
|
||||
|
||||
inline int RunEditor(HINSTANCE hInstance, int nCmdShow) {
|
||||
UI::ImGuiBackendBridge::EnableDpiAwareness();
|
||||
|
||||
WNDCLASSEXW wc = {};
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.style = CS_CLASSDC;
|
||||
wc.lpfnWndProc = EditorWndProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = static_cast<HICON>(LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_APP_ICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE));
|
||||
wc.hIconSm = static_cast<HICON>(LoadImageW(
|
||||
hInstance,
|
||||
MAKEINTRESOURCEW(IDI_APP_ICON),
|
||||
IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON),
|
||||
GetSystemMetrics(SM_CYSMICON),
|
||||
LR_DEFAULTCOLOR));
|
||||
wc.lpszClassName = L"XCVolumeRendererUI2";
|
||||
|
||||
if (!RegisterClassExW(&wc)) {
|
||||
@@ -64,6 +89,13 @@ inline int RunEditor(HINSTANCE hInstance, int nCmdShow) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (wc.hIcon) {
|
||||
SendMessageW(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(wc.hIcon));
|
||||
}
|
||||
if (wc.hIconSm) {
|
||||
SendMessageW(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(wc.hIconSm));
|
||||
}
|
||||
|
||||
ShowWindow(hwnd, nCmdShow);
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user