14#include "imgui_impl_win32.h"
15#include "imgui_impl_dx12.h"
27#include "implot_internal.h"
29#include <imgui-node-editor/imgui_node_editor.h>
33#define DX12_ENABLE_DEBUG_LAYER
36#ifdef DX12_ENABLE_DEBUG_LAYER
38#pragma comment(lib, "dxguid.lib")
112 WNDCLASSEXW windowClass;
113 std::vector<std::shared_ptr<UserInterfaceWindow>> windows;
114 bool shutdownRequest;
156 template<
typename T,
typename... Args>
159 auto window = std::make_shared<T>(std::forward<Args>(args)...);
160 windows.push_back(std::move(window));
163 void loadIcon()
const;
165 void loadBackgroundImage();
166 void renderWindows()
const;
167 void renderBackgroundImage()
const;
168 void updateLastRenderedFrameDimensions();
178 ID3D12CommandAllocator* CommandAllocator;
183inline int constexpr NUM_FRAMES_IN_FLIGHT = 3;
184inline FrameContext g_frameContext[NUM_FRAMES_IN_FLIGHT] = {};
185inline UINT g_frameIndex = 0;
186inline int constexpr NUM_BACK_BUFFERS = 3;
187inline int constexpr SRV_HEAP_SIZE = 64;
188inline ID3D12Device* g_pd3dDevice =
nullptr;
189inline ID3D12DescriptorHeap* g_pd3dRtvDescHeap =
nullptr;
190inline ID3D12DescriptorHeap* g_pd3dSrvDescHeap =
nullptr;
191inline ID3D12CommandQueue* g_pd3dCommandQueue =
nullptr;
192inline ID3D12GraphicsCommandList* g_pd3dCommandList =
nullptr;
193inline ID3D12Fence* g_fence =
nullptr;
194inline HANDLE g_fenceEvent =
nullptr;
195inline UINT64 g_fenceLastSignaledValue = 0;
196inline IDXGISwapChain3* g_pSwapChain =
nullptr;
197inline HANDLE g_hSwapChainWaitableObject =
nullptr;
198inline ID3D12Resource* g_mainRenderTargetResource[NUM_BACK_BUFFERS] = {};
199inline D3D12_CPU_DESCRIPTOR_HANDLE g_mainRenderTargetDescriptor[NUM_BACK_BUFFERS] = {};
200inline UINT g_SrvDescriptorSize = 0;
201inline std::vector<UINT> g_SrvFreeSlots;
204bool CreateDeviceD3D(HWND hWnd);
205void CleanupDeviceD3D();
206void CreateRenderTarget();
207void CleanupRenderTarget();
208void WaitForLastSubmittedFrame();
209FrameContext* WaitForNextFrameResources();
210LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
211bool LoadTextureFromFile(
const char* filename, ID3D12Device* d3d_device, D3D12_CPU_DESCRIPTOR_HANDLE srv_cpu_handle, ID3D12Resource** out_tex_resource,
int* out_width,
int* out_height);
212std::wstring StringToWString(
const std::string& str);
213float GetDpiScale(HWND hWnd);
214void ImGui_ImplDX12_SrvDescAlloc(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu);
215void ImGui_ImplDX12_SrvDescFree(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE cpu, D3D12_GPU_DESCRIPTOR_HANDLE gpu);
Main application object: owns the platform window, the rendering backend and the registered UserInter...
Definition win32_dx12_user_interface.h:107
void addWindow(Args &&... args)
Constructs a window of type T and registers it for rendering.
Definition win32_dx12_user_interface.h:157
void shutdown()
Destroys the rendering backend, the ImGui contexts and the platform window.
bool isShutdownRequested() const
Returns true once the user has requested to close the window.
void initialize()
Creates the platform window, sets up the rendering backend and the ImGui/ImPlot/node-editor contexts,...
UserInterface(UserInterfaceParameters parameters)
Constructs the interface with the given parameters.
void render()
Renders one frame: processes platform events and calls render() on every registered window.
UserInterface()
Constructs the interface with default UserInterfaceParameters.
Definition colour_palette.h:11
Background image drawn behind all windows.
Definition user_interface_parameters.h:167
D3D12 texture holding the background image and its parameters.
Definition win32_dx12_user_interface.h:53
ID3D12Resource * texture
Definition win32_dx12_user_interface.h:54
BackgroundImageParameters parameters
Definition win32_dx12_user_interface.h:57
DX12BackgroundImageTexture()
Definition win32_dx12_user_interface.h:59
D3D12_GPU_DESCRIPTOR_HANDLE srv_gpu_handle
Definition win32_dx12_user_interface.h:56
DX12BackgroundImageTexture(BackgroundImageParameters parameters)
Definition win32_dx12_user_interface.h:67
void release()
Definition win32_dx12_user_interface.h:74
D3D12_CPU_DESCRIPTOR_HANDLE srv_cpu_handle
Definition win32_dx12_user_interface.h:55
~DX12BackgroundImageTexture()
Definition win32_dx12_user_interface.h:81
Aggregates all configuration passed to imgui_kit::UserInterface.
Definition user_interface_parameters.h:189
Configuration structures used to set up an imgui_kit::UserInterface.
Abstract base class for user-defined windows and global window flags.