1

I've got a dxgiswapchain and d3d11device, and I would like to fetch a HWND from either of the two.

void OnPresent(IDXGISwapChain *swapChain) {
    ID3D11Device *device = NULL;
    swapChain->GetDevice(__uuidof(ID3D11Device), (void**)&device);
}

How can I do so? I briefly remember it being possible with d3d9, so I'm not sure if the same is possible with dxgi/d3d11.

Bork
  • 21
  • 4
  • 3
    IDXGISwapChain::GetDesc will get you a DXGI_SWAP_CHAIN_DESC with a OutputWindow member of type HWND if that's what you're looking for – Simon Mourier Oct 22 '22 at 16:16
  • Thank you! I will give that a shot, and hope that it works with imgui. – Bork Oct 22 '22 at 16:53

1 Answers1

2

Calling IDXGISwapChain::GetDesc will give you the swap chain description, it contains the HWND to the output window:

DXGI_SWAP_CHAIN_DESC swapChainDesc;
swapChain->GetDesc(&swapChainDesc);

swapChainDesc.OutputWindow; // the hwnd
thedemons
  • 1,139
  • 2
  • 9
  • 25