mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Examples: DX9, DX10, DX11: Queue framebuffer resize instead of processing in WM_SIZE. (#6374)
This commit is contained in:
		| @@ -64,6 +64,8 @@ Other changes: | ||||
| - Examples: Added native Win32+OpenGL3 example. We don't recommend using this setup but we | ||||
|   provide it for completeness. (#3218, #5170, #6086, #2772, #2600, #2359, #2022, #1553) [@learn-more] | ||||
| - Examples: Vulkan: Use integrated GPU if nothing else is available. (#6359) [@kimidaisuki22] | ||||
| - Examples: DX9, DX10, DX11: Queue framebuffer resize instead of processing in WM_SIZE, | ||||
|   as some drivers tends to only cleanup after existing the native resize modal loop. (#6374) | ||||
|  | ||||
|  | ||||
| ----------------------------------------------------------------------- | ||||
|   | ||||
| @@ -12,6 +12,7 @@ | ||||
| // Data | ||||
| static ID3D10Device*            g_pd3dDevice = nullptr; | ||||
| static IDXGISwapChain*          g_pSwapChain = nullptr; | ||||
| static UINT                     g_ResizeWidth = 0, g_ResizeHeight = 0; | ||||
| static ID3D10RenderTargetView*  g_mainRenderTargetView = nullptr; | ||||
|  | ||||
| // Forward declarations of helper functions | ||||
| @@ -95,6 +96,15 @@ int main(int, char**) | ||||
|         if (done) | ||||
|             break; | ||||
|  | ||||
|         // Handle window resize (we don't resize directly in the WM_SIZE handler) | ||||
|         if (g_ResizeWidth != 0 && g_ResizeHeight != 0) | ||||
|         { | ||||
|             CleanupRenderTarget(); | ||||
|             g_pSwapChain->ResizeBuffers(0, g_ResizeWidth, g_ResizeHeight, DXGI_FORMAT_UNKNOWN, 0); | ||||
|             g_ResizeWidth = g_ResizeHeight = 0; | ||||
|             CreateRenderTarget(); | ||||
|         } | ||||
|  | ||||
|         // Start the Dear ImGui frame | ||||
|         ImGui_ImplDX10_NewFrame(); | ||||
|         ImGui_ImplWin32_NewFrame(); | ||||
| @@ -228,12 +238,10 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | ||||
|     switch (msg) | ||||
|     { | ||||
|     case WM_SIZE: | ||||
|         if (g_pd3dDevice != nullptr && wParam != SIZE_MINIMIZED) | ||||
|         { | ||||
|             CleanupRenderTarget(); | ||||
|             g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0); | ||||
|             CreateRenderTarget(); | ||||
|         } | ||||
|         if (wParam == SIZE_MINIMIZED) | ||||
|             return 0; | ||||
|         g_ResizeWidth = (UINT)LOWORD(lParam); // Queue resize | ||||
|         g_ResizeHeight = (UINT)HIWORD(lParam); | ||||
|         return 0; | ||||
|     case WM_SYSCOMMAND: | ||||
|         if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu | ||||
|   | ||||
| @@ -12,6 +12,7 @@ | ||||
| static ID3D11Device*            g_pd3dDevice = nullptr; | ||||
| static ID3D11DeviceContext*     g_pd3dDeviceContext = nullptr; | ||||
| static IDXGISwapChain*          g_pSwapChain = nullptr; | ||||
| static UINT                     g_ResizeWidth = 0, g_ResizeHeight = 0; | ||||
| static ID3D11RenderTargetView*  g_mainRenderTargetView = nullptr; | ||||
|  | ||||
| // Forward declarations of helper functions | ||||
| @@ -95,6 +96,15 @@ int main(int, char**) | ||||
|         if (done) | ||||
|             break; | ||||
|  | ||||
|         // Handle window resize (we don't resize directly in the WM_SIZE handler) | ||||
|         if (g_ResizeWidth != 0 && g_ResizeHeight != 0) | ||||
|         { | ||||
|             CleanupRenderTarget(); | ||||
|             g_pSwapChain->ResizeBuffers(0, g_ResizeWidth, g_ResizeHeight, DXGI_FORMAT_UNKNOWN, 0); | ||||
|             g_ResizeWidth = g_ResizeHeight = 0; | ||||
|             CreateRenderTarget(); | ||||
|         } | ||||
|  | ||||
|         // Start the Dear ImGui frame | ||||
|         ImGui_ImplDX11_NewFrame(); | ||||
|         ImGui_ImplWin32_NewFrame(); | ||||
| @@ -232,12 +242,10 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | ||||
|     switch (msg) | ||||
|     { | ||||
|     case WM_SIZE: | ||||
|         if (g_pd3dDevice != nullptr && wParam != SIZE_MINIMIZED) | ||||
|         { | ||||
|             CleanupRenderTarget(); | ||||
|             g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0); | ||||
|             CreateRenderTarget(); | ||||
|         } | ||||
|         if (wParam == SIZE_MINIMIZED) | ||||
|             return 0; | ||||
|         g_ResizeWidth = (UINT)LOWORD(lParam); // Queue resize | ||||
|         g_ResizeHeight = (UINT)HIWORD(lParam); | ||||
|         return 0; | ||||
|     case WM_SYSCOMMAND: | ||||
|         if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| // Data | ||||
| static LPDIRECT3D9              g_pD3D = nullptr; | ||||
| static LPDIRECT3DDEVICE9        g_pd3dDevice = nullptr; | ||||
| static UINT                     g_ResizeWidth = 0, g_ResizeHeight = 0; | ||||
| static D3DPRESENT_PARAMETERS    g_d3dpp = {}; | ||||
|  | ||||
| // Forward declarations of helper functions | ||||
| @@ -93,6 +94,14 @@ int main(int, char**) | ||||
|         if (done) | ||||
|             break; | ||||
|  | ||||
|         // Handle window resize (we don't resize directly in the WM_SIZE handler) | ||||
|         if (g_ResizeWidth != 0 && g_ResizeHeight != 0) | ||||
|         { | ||||
|             g_d3dpp.BackBufferWidth = g_ResizeWidth; | ||||
|             g_d3dpp.BackBufferHeight = g_ResizeHeight; | ||||
|             ResetDevice(); | ||||
|         } | ||||
|  | ||||
|         // Start the Dear ImGui frame | ||||
|         ImGui_ImplDX9_NewFrame(); | ||||
|         ImGui_ImplWin32_NewFrame(); | ||||
| @@ -219,12 +228,10 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | ||||
|     switch (msg) | ||||
|     { | ||||
|     case WM_SIZE: | ||||
|         if (g_pd3dDevice != nullptr && wParam != SIZE_MINIMIZED) | ||||
|         { | ||||
|             g_d3dpp.BackBufferWidth = LOWORD(lParam); | ||||
|             g_d3dpp.BackBufferHeight = HIWORD(lParam); | ||||
|             ResetDevice(); | ||||
|         } | ||||
|         if (wParam == SIZE_MINIMIZED) | ||||
|             return 0; | ||||
|         g_ResizeWidth = (UINT)LOWORD(lParam); // Queue resize | ||||
|         g_ResizeHeight = (UINT)HIWORD(lParam); | ||||
|         return 0; | ||||
|     case WM_SYSCOMMAND: | ||||
|         if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ocornut
					ocornut