diff --git a/examples/directx12_example/imgui_impl_dx12.cpp b/examples/directx12_example/imgui_impl_dx12.cpp index 8f81b007..b0b65d7d 100644 --- a/examples/directx12_example/imgui_impl_dx12.cpp +++ b/examples/directx12_example/imgui_impl_dx12.cpp @@ -32,6 +32,7 @@ static ID3D10Blob* g_pVertexShaderBlob = NULL; static ID3D10Blob* g_pPixelShaderBlob = NULL; static ID3D12RootSignature* g_pRootSignature = NULL; static ID3D12PipelineState* g_pPipelineState = NULL; +static DXGI_FORMAT g_RTVFormat = DXGI_FORMAT_UNKNOWN; static ID3D12Resource* g_pFontTextureResource = NULL; static D3D12_CPU_DESCRIPTOR_HANDLE g_hFontSrvCpuDescHandle = {}; static D3D12_GPU_DESCRIPTOR_HANDLE g_hFontSrvGpuDescHandle = {}; @@ -489,7 +490,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects() psoDesc.pRootSignature = g_pRootSignature; psoDesc.SampleMask = UINT_MAX; psoDesc.NumRenderTargets = 1; - psoDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; + psoDesc.RTVFormats[0] = g_RTVFormat; psoDesc.SampleDesc.Count = 1; psoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; @@ -630,11 +631,13 @@ void ImGui_ImplDX12_InvalidateDeviceObjects() bool ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight, ID3D12Device* device, + DXGI_FORMAT rtv_format, D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle) { g_hWnd = (HWND)hwnd; g_pd3dDevice = device; + g_RTVFormat = rtv_format; g_hFontSrvCpuDescHandle = font_srv_cpu_desc_handle; g_hFontSrvGpuDescHandle = font_srv_gpu_desc_handle; g_pFrameResources = new FrameResources [num_frames_in_flight]; diff --git a/examples/directx12_example/imgui_impl_dx12.h b/examples/directx12_example/imgui_impl_dx12.h index 7bc828eb..059d73e1 100644 --- a/examples/directx12_example/imgui_impl_dx12.h +++ b/examples/directx12_example/imgui_impl_dx12.h @@ -6,6 +6,7 @@ // If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui +enum DXGI_FORMAT; struct ID3D12Device; struct ID3D12GraphicsCommandList; struct D3D12_CPU_DESCRIPTOR_HANDLE; @@ -22,6 +23,7 @@ struct D3D12_GPU_DESCRIPTOR_HANDLE; // descriptor to use for the internal font texture. IMGUI_API bool ImGui_ImplDX12_Init(void* hwnd, int numFramesInFlight, ID3D12Device* device, + DXGI_FORMAT rtv_format, D3D12_CPU_DESCRIPTOR_HANDLE fontSrvCpuDescHandle, D3D12_GPU_DESCRIPTOR_HANDLE fontSrvGpuDescHandle); IMGUI_API void ImGui_ImplDX12_Shutdown(); diff --git a/examples/directx12_example/main.cpp b/examples/directx12_example/main.cpp index 4bca2a29..51b9da4e 100644 --- a/examples/directx12_example/main.cpp +++ b/examples/directx12_example/main.cpp @@ -301,6 +301,7 @@ int main(int, char**) // Setup ImGui binding ImGui_ImplDX12_Init(hwnd, NUM_FRAMES_IN_FLIGHT, g_pd3dDevice, + DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(), g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());