mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-30 12:41:06 +01:00 
			
		
		
		
	Pass command list in using ImGui_ImplDX12_NewFrame() instead of ImGui_ImplDX12_Init()
This commit is contained in:
		
				
					committed by
					
						 Jefferson Montgomery
						Jefferson Montgomery
					
				
			
			
				
	
			
			
			
						parent
						
							f72b95d73f
						
					
				
				
					commit
					f6b6dace9e
				
			| @@ -629,13 +629,12 @@ void    ImGui_ImplDX12_InvalidateDeviceObjects() | ||||
| } | ||||
|  | ||||
| bool    ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight, | ||||
|                             ID3D12Device* device, ID3D12GraphicsCommandList* command_list, | ||||
|                             ID3D12Device* device, | ||||
|                             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_pd3dCommandList = command_list; | ||||
|     g_hFontSrvCpuDescHandle = font_srv_cpu_desc_handle; | ||||
|     g_hFontSrvGpuDescHandle = font_srv_gpu_desc_handle; | ||||
|     g_pFrameResources = new FrameResources [num_frames_in_flight]; | ||||
| @@ -697,11 +696,13 @@ void ImGui_ImplDX12_Shutdown() | ||||
|     g_frameIndex = UINT_MAX; | ||||
| } | ||||
|  | ||||
| void ImGui_ImplDX12_NewFrame() | ||||
| void ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* command_list) | ||||
| { | ||||
|     if (!g_pPipelineState) | ||||
|         ImGui_ImplDX12_CreateDeviceObjects(); | ||||
|  | ||||
|     g_pd3dCommandList = command_list; | ||||
|  | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|  | ||||
|     // Setup display size (every frame to accommodate for window resizing) | ||||
|   | ||||
| @@ -21,11 +21,11 @@ struct D3D12_GPU_DESCRIPTOR_HANDLE; | ||||
| // fontSrvCpuDescHandle and fontSrvGpuDescHandle are handles to a single SRV | ||||
| // descriptor to use for the internal font texture. | ||||
| IMGUI_API bool        ImGui_ImplDX12_Init(void* hwnd, int numFramesInFlight, | ||||
|                                           ID3D12Device* device, ID3D12GraphicsCommandList* cmdList, | ||||
|                                           ID3D12Device* device, | ||||
|                                           D3D12_CPU_DESCRIPTOR_HANDLE fontSrvCpuDescHandle, | ||||
|                                           D3D12_GPU_DESCRIPTOR_HANDLE fontSrvGpuDescHandle); | ||||
| IMGUI_API void        ImGui_ImplDX12_Shutdown(); | ||||
| IMGUI_API void        ImGui_ImplDX12_NewFrame(); | ||||
| IMGUI_API void        ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* cmdList); | ||||
|  | ||||
| // Use if you want to reset your rendering device without losing ImGui state. | ||||
| IMGUI_API void        ImGui_ImplDX12_InvalidateDeviceObjects(); | ||||
|   | ||||
| @@ -300,7 +300,7 @@ int main(int, char**) | ||||
|     UpdateWindow(hwnd); | ||||
|  | ||||
|     // Setup ImGui binding | ||||
|     ImGui_ImplDX12_Init(hwnd, NUM_FRAMES_IN_FLIGHT, g_pd3dDevice, g_pd3dCommandList, | ||||
|     ImGui_ImplDX12_Init(hwnd, NUM_FRAMES_IN_FLIGHT, g_pd3dDevice, | ||||
|         g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(), | ||||
|         g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart()); | ||||
|  | ||||
| @@ -329,7 +329,7 @@ int main(int, char**) | ||||
|             DispatchMessage(&msg); | ||||
|             continue; | ||||
|         } | ||||
|         ImGui_ImplDX12_NewFrame(); | ||||
|         ImGui_ImplDX12_NewFrame(g_pd3dCommandList); | ||||
|  | ||||
|         // 1. Show a simple window | ||||
|         // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user