Browse Source

Examples: DX10, DX11: Disabled DXGI's Alt+Enter default behavior in examples. (#4350)

David Maas 2 weeks ago
parent
commit
3d937beb62

+ 3 - 0
docs/CHANGELOG.txt

@@ -92,6 +92,9 @@ Docking+Viewports Branch:
   viewports managed by the backend. (#4350) [@PathogenDavid]
   viewports managed by the backend. (#4350) [@PathogenDavid]
 - Backends: Vulkan: Added ImGui_ImplVulkanH_GetWindowDataFromViewport() accessor/helper.
 - Backends: Vulkan: Added ImGui_ImplVulkanH_GetWindowDataFromViewport() accessor/helper.
   (#8946, #8940) [@olivier-gerard]
   (#8946, #8940) [@olivier-gerard]
+- Examples: DX10, DX11: Disabled DXGI's Alt+Enter default behavior in examples.
+  Applications are free to leave this enabled, but it does not work properly with
+  multiple viewports. (#4350) [@PathogenDavid]
 
 
 
 
 -----------------------------------------------------------------------
 -----------------------------------------------------------------------

+ 7 - 0
examples/example_sdl2_directx11/main.cpp

@@ -256,6 +256,13 @@ bool CreateDeviceD3D(HWND hWnd)
     if (res != S_OK)
     if (res != S_OK)
         return false;
         return false;
 
 
+    // Disable DXGI's default Alt+Enter fullscreen behavior.
+    // - You are free to leave this enabled, but it will not work properly with multiple viewports.
+    // - This must be done for all windows associated to the device. Our DX11 backend does this automatically for secondary viewports that it creates.
+    IDXGIFactory* pSwapChainFactory;
+    if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory))))
+        pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);
+
     CreateRenderTarget();
     CreateRenderTarget();
     return true;
     return true;
 }
 }

+ 7 - 0
examples/example_sdl3_directx11/main.cpp

@@ -251,6 +251,13 @@ bool CreateDeviceD3D(HWND hWnd)
     if (res != S_OK)
     if (res != S_OK)
         return false;
         return false;
 
 
+    // Disable DXGI's default Alt+Enter fullscreen behavior.
+    // - You are free to leave this enabled, but it will not work properly with multiple viewports.
+    // - This must be done for all windows associated to the device. Our DX11 backend does this automatically for secondary viewports that it creates.
+    IDXGIFactory* pSwapChainFactory;
+    if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory))))
+        pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);
+
     CreateRenderTarget();
     CreateRenderTarget();
     return true;
     return true;
 }
 }

+ 7 - 0
examples/example_win32_directx10/main.cpp

@@ -241,6 +241,13 @@ bool CreateDeviceD3D(HWND hWnd)
     if (res != S_OK)
     if (res != S_OK)
         return false;
         return false;
 
 
+    // Disable DXGI's default Alt+Enter fullscreen behavior.
+    // - You are free to leave this enabled, but it will not work properly with multiple viewports.
+    // - This must be done for all windows associated to the device. Our DX11 backend does this automatically for secondary viewports that it creates.
+    IDXGIFactory* pSwapChainFactory;
+    if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory))))
+        pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);
+
     CreateRenderTarget();
     CreateRenderTarget();
     return true;
     return true;
 }
 }

+ 7 - 0
examples/example_win32_directx11/main.cpp

@@ -245,6 +245,13 @@ bool CreateDeviceD3D(HWND hWnd)
     if (res != S_OK)
     if (res != S_OK)
         return false;
         return false;
 
 
+    // Disable DXGI's default Alt+Enter fullscreen behavior.
+    // - You are free to leave this enabled, but it will not work properly with multiple viewports.
+    // - This must be done for all windows associated to the device. Our DX11 backend does this automatically for secondary viewports that it creates.
+    IDXGIFactory* pSwapChainFactory;
+    if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory))))
+        pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);
+
     CreateRenderTarget();
     CreateRenderTarget();
     return true;
     return true;
 }
 }