8000 Disable DXGI window management features for swap chains owned by the backend by PathogenDavid · Pull Request #4350 · ocornut/imgui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Disable DXGI window management features for swap chains owned by the backend #4350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: docking
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backends/imgui_impl_dx10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport)

IM_ASSERT(vd->SwapChain == NULL && vd->RTView == NULL);
bd->pFactory->CreateSwapChain(bd->pd3dDevice, &sd, &vd->SwapChain);
bd->pFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN | DXGI_MWA_NO_WINDOW_CHANGES);

// Create the render target
if (vd->SwapChain)
Expand Down
1 change: 1 addition & 0 deletions backends/imgui_impl_dx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)

IM_ASSERT(vd->SwapChain == NULL && vd->RTView == NULL);
bd->pFactory->CreateSwapChain(bd->pd3dDevice, &sd, &vd->SwapChain);
bd->pFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN | DXGI_MWA_NO_WINDOW_CHANGES);

// Create the render target
if (vd->SwapChain)
Expand Down
2 changes: 2 additions & 0 deletions backends/imgui_impl_dx12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,8 @@ static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport)
IDXGISwapChain1* swap_chain = NULL;
res = dxgi_factory->CreateSwapChainForHwnd(vd->CommandQueue, hwnd, &sd1, NULL, NULL, &swap_chain);
IM_ASSERT(res == S_OK);
res = dxgi_factory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN | DXGI_MWA_NO_WINDOW_CHANGES);
IM_ASSERT(res == S_OK);

dxgi_factory->Release();

Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ Docking+Viewports Branch:
- Viewports: Fix popup/tooltip created without a parent window from being given a ParentViewportId value
from the implicit/fallback window. (#4236, #2409)
- Backends: Vulkan: Fix the use of the incorrect fence for secondary viewports. (#4208) [@FunMiles]
- Examples: Disabled DXGI's automatic alt+enter fullscreen for DirectX 10/11 samples. Applications are free to
leave this enabled, but it does not work properly with multiple viewports. (#4350) [@PathogenDavid]


-----------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions examples/example_sdl_directx11/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ bool CreateDeviceD3D(HWND hWnd)
if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
return false;

// Disable DXGI's automatic alt+enter fullscreen
// You are free to leave this enabled, but it will not work properly with multiple viewports
// For DirectX 11, this must be done for all windows associated with the device
IDXGIFactory* pSwapChainFactory;
if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory))))
pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);

CreateRenderTarget();
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions examples/example_win32_directx10/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ bool CreateDeviceD3D(HWND hWnd)
if (D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice) != S_OK)
return false;

// Disable DXGI's window management features (namely automatic alt+enter fullscreen)
// You are free to leave this enabled, but it will not work properly with multiple viewports
// For DirectX 10, this must be done for all windows associated with the device
IDXGIFactory* pSwapChainFactory;
if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory))))
pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_WINDOW_CHANGES);

CreateRenderTarget();
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions examples/example_win32_directx11/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ bool CreateDeviceD3D(HWND hWnd)
if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
return false;

// Disable DXGI's automatic alt+enter fullscreen
// You are free to leave this enabled, but it will not work properly with multiple viewports
// For DirectX 11, this must be done for all windows associated with the device
IDXGIFactory* pSwapChainFactory;
if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory))))
pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);

CreateRenderTarget();
return true;
}
Expand Down
0