2021年5月5日星期三

Get new connected display via existing IDXGIDevice

I have a program that creates ID3D11Device device on start and destroys on shutdown. I encountered the issue when I connected the second monitor after ID3D11Device was created. In this simplified piece of code it enumerates adapter outputs and this enumeration returns only one monitor, the first one that had been connected before program started.

A

IDXGIDevice* DXGIDevice;  D3D11Device->QueryInterface(IID_IDXGIDevice, (void**)&DXGIDevice);    IDXGIAdapter* DXGIAdapter;  DXGIDevice->GetAdapter(&DXGIAdapter);    IDXGIOutput* Output;  int i = 0;  while (DXGIAdapter->EnumOutputs(i, &Output) != DXGI_ERROR_NOT_FOUND)  {      DXGI_OUTPUT_DESC desc;      Output->GetDesc(&desc);        PrintMonitor(desc.Monitor);  }  

But if I try manually create factory and get main adapter, it enumerates both monitors.

B

IDXGIFactory* DXGIFactory;  IDXGIAdapter* DXGIAdapter;    CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&DXGIFactory);  factory->EnumAdapters(0, &DXGIAdapter);    IDXGIOutput* Output;  int i = 0;  while (DXGIAdapter->EnumOutputs(i, &Output) != DXGI_ERROR_NOT_FOUND)  {      DXGI_OUTPUT_DESC desc;      Output->GetDesc(&desc);        PrintMonitor(desc.Monitor);  }  

My question is: is this possible "refresh" outputs list of adapter that was get from DXGIDevice device without this device recreation, and see any monitors plug-in/plug-out in code like the first one (A)?

https://stackoverflow.com/questions/67390626/get-new-connected-display-via-existing-idxgidevice May 05, 2021 at 02:59AM

没有评论:

发表评论