mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Examples: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from ImGui_ImplDX12_NewFrame() to ImGui_ImplDX12_RenderDrawData() which makes a lots more sense. (#301)
This commit is contained in:
parent
cac4c3f9b8
commit
f9a5ff7a19
@ -83,6 +83,7 @@ Other Changes:
|
|||||||
- Examples: Added SDL+Vulkan example.
|
- Examples: Added SDL+Vulkan example.
|
||||||
- Examples: Allegro5: Added support for ImGuiConfigFlags_NoMouseCursorChange flag. Added clipboard support.
|
- Examples: Allegro5: Added support for ImGuiConfigFlags_NoMouseCursorChange flag. Added clipboard support.
|
||||||
- Examples: Allegro5: Unindexing buffers ourselves as Allegro indexed drawing primitives are buggy in the DirectX9 back-end.
|
- Examples: Allegro5: Unindexing buffers ourselves as Allegro indexed drawing primitives are buggy in the DirectX9 back-end.
|
||||||
|
- Examples: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from ImGui_ImplDX12_NewFrame() to ImGui_ImplDX12_RenderDrawData() which makes a lots more sense. (#301)
|
||||||
- Examples: FreeGLUT: Added FreeGLUT bindings. Added FreeGLUT+OpenGL2 example. (#801)
|
- Examples: FreeGLUT: Added FreeGLUT bindings. Added FreeGLUT+OpenGL2 example. (#801)
|
||||||
- Examples: The functions in imgui_impl_xxx.cpp are prefixed with IMGUI_IMPL_API (which defaults to IMGUI_API) to facilitate some uses. (#1888)
|
- Examples: The functions in imgui_impl_xxx.cpp are prefixed with IMGUI_IMPL_API (which defaults to IMGUI_API) to facilitate some uses. (#1888)
|
||||||
- Examples: Fixed bindings to use ImGuiMouseCursor_COUNT instead of old name ImGuiMouseCursor_Count_ so they can compile with IMGUI_DISABLE_OBSOLETE_FUNCTIONS. (#1887)
|
- Examples: Fixed bindings to use ImGuiMouseCursor_COUNT instead of old name ImGuiMouseCursor_Count_ so they can compile with IMGUI_DISABLE_OBSOLETE_FUNCTIONS. (#1887)
|
||||||
|
@ -339,7 +339,7 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start the ImGui frame
|
// Start the ImGui frame
|
||||||
ImGui_ImplDX12_NewFrame(g_pd3dCommandList);
|
ImGui_ImplDX12_NewFrame();
|
||||||
ImGui_ImplWin32_NewFrame();
|
ImGui_ImplWin32_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ int main(int, char**)
|
|||||||
g_pd3dCommandList->OMSetRenderTargets(1, &g_mainRenderTargetDescriptor[backBufferIdx], FALSE, NULL);
|
g_pd3dCommandList->OMSetRenderTargets(1, &g_mainRenderTargetDescriptor[backBufferIdx], FALSE, NULL);
|
||||||
g_pd3dCommandList->SetDescriptorHeaps(1, &g_pd3dSrvDescHeap);
|
g_pd3dCommandList->SetDescriptorHeaps(1, &g_pd3dSrvDescHeap);
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), g_pd3dCommandList);
|
||||||
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||||
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
|
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
|
||||||
g_pd3dCommandList->ResourceBarrier(1, &barrier);
|
g_pd3dCommandList->ResourceBarrier(1, &barrier);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
// ImGui Win32 + DirectX12 binding
|
// ImGui Renderer for: DirectX12
|
||||||
// FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*))
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// Issues:
|
||||||
|
// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
@ -11,6 +13,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2018-06-12: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from NewFrame() to RenderDrawData().
|
||||||
// 2018-06-08: Misc: Extracted imgui_impl_dx12.cpp/.h away from the old combined DX12+Win32 example.
|
// 2018-06-08: Misc: Extracted imgui_impl_dx12.cpp/.h away from the old combined DX12+Win32 example.
|
||||||
// 2018-06-08: DirectX12: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle (to ease support for future multi-viewport).
|
// 2018-06-08: DirectX12: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle (to ease support for future multi-viewport).
|
||||||
// 2018-02-22: Merged into master with all Win32 code synchronized to other examples.
|
// 2018-02-22: Merged into master with all Win32 code synchronized to other examples.
|
||||||
@ -25,7 +28,6 @@
|
|||||||
|
|
||||||
// DirectX data
|
// DirectX data
|
||||||
static ID3D12Device* g_pd3dDevice = NULL;
|
static ID3D12Device* g_pd3dDevice = NULL;
|
||||||
static ID3D12GraphicsCommandList* g_pd3dCommandList = NULL;
|
|
||||||
static ID3D10Blob* g_pVertexShaderBlob = NULL;
|
static ID3D10Blob* g_pVertexShaderBlob = NULL;
|
||||||
static ID3D10Blob* g_pPixelShaderBlob = NULL;
|
static ID3D10Blob* g_pPixelShaderBlob = NULL;
|
||||||
static ID3D12RootSignature* g_pRootSignature = NULL;
|
static ID3D12RootSignature* g_pRootSignature = NULL;
|
||||||
@ -53,7 +55,7 @@ struct VERTEX_CONSTANT_BUFFER
|
|||||||
|
|
||||||
// Render function
|
// Render function
|
||||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||||
void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx)
|
||||||
{
|
{
|
||||||
// FIXME: I'm assuming that this only gets called once per frame!
|
// FIXME: I'm assuming that this only gets called once per frame!
|
||||||
// If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator.
|
// If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator.
|
||||||
@ -63,7 +65,6 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ID3D12Resource* g_pIB = frameResources->IB;
|
ID3D12Resource* g_pIB = frameResources->IB;
|
||||||
int g_VertexBufferSize = frameResources->VertexBufferSize;
|
int g_VertexBufferSize = frameResources->VertexBufferSize;
|
||||||
int g_IndexBufferSize = frameResources->IndexBufferSize;
|
int g_IndexBufferSize = frameResources->IndexBufferSize;
|
||||||
ID3D12GraphicsCommandList* ctx = g_pd3dCommandList;
|
|
||||||
|
|
||||||
// Create and grow vertex/index buffers if needed
|
// Create and grow vertex/index buffers if needed
|
||||||
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
@ -594,6 +595,7 @@ bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FO
|
|||||||
g_numFramesInFlight = num_frames_in_flight;
|
g_numFramesInFlight = num_frames_in_flight;
|
||||||
g_frameIndex = UINT_MAX;
|
g_frameIndex = UINT_MAX;
|
||||||
|
|
||||||
|
// Create buffers with a default size (they will later be grown as needed)
|
||||||
for (int i = 0; i < num_frames_in_flight; i++)
|
for (int i = 0; i < num_frames_in_flight; i++)
|
||||||
{
|
{
|
||||||
g_pFrameResources[i].IB = NULL;
|
g_pFrameResources[i].IB = NULL;
|
||||||
@ -610,7 +612,6 @@ void ImGui_ImplDX12_Shutdown()
|
|||||||
ImGui_ImplDX12_InvalidateDeviceObjects();
|
ImGui_ImplDX12_InvalidateDeviceObjects();
|
||||||
delete[] g_pFrameResources;
|
delete[] g_pFrameResources;
|
||||||
g_pd3dDevice = NULL;
|
g_pd3dDevice = NULL;
|
||||||
g_pd3dCommandList = NULL;
|
|
||||||
g_hFontSrvCpuDescHandle.ptr = 0;
|
g_hFontSrvCpuDescHandle.ptr = 0;
|
||||||
g_hFontSrvGpuDescHandle.ptr = 0;
|
g_hFontSrvGpuDescHandle.ptr = 0;
|
||||||
g_pFrameResources = NULL;
|
g_pFrameResources = NULL;
|
||||||
@ -618,10 +619,8 @@ void ImGui_ImplDX12_Shutdown()
|
|||||||
g_frameIndex = UINT_MAX;
|
g_frameIndex = UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* command_list)
|
void ImGui_ImplDX12_NewFrame()
|
||||||
{
|
{
|
||||||
if (!g_pPipelineState)
|
if (!g_pPipelineState)
|
||||||
ImGui_ImplDX12_CreateDeviceObjects();
|
ImGui_ImplDX12_CreateDeviceObjects();
|
||||||
|
|
||||||
g_pd3dCommandList = command_list;
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
// ImGui Win32 + DirectX12 binding
|
// ImGui Renderer for: DirectX12
|
||||||
// FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*))
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// Issues:
|
||||||
|
// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
@ -22,8 +24,8 @@ struct D3D12_GPU_DESCRIPTOR_HANDLE;
|
|||||||
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format,
|
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format,
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
|
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* cmd_list);
|
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data);
|
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
|
||||||
|
Loading…
Reference in New Issue
Block a user