Game Development Reference
In-Depth Information
need to convert the ID3D11Device1 to an IDXGIDevice1 with the following piece
of code:
ComPtr<IDXGIDevice1> dxgiDevice;
DX::ThrowIfFailed(m_d3dDevice.As(&dxgiDevice));
Then we can get the adapter that the device is linked to, and the factory that serves
the adapter, with the following code snippet:
ComPtr<IDXGIAdapter> dxgiAdapter;
DX::ThrowIfFailed(
dxgiDevice->GetAdapter(&dxgiAdapter));
ComPtr<IDXGIFactory2> dxgiFactory;
DX::ThrowIfFailed(
dxgiAdapter->GetParent(
__uuidof(IDXGIFactory2),
&dxgiFactory
));
Using the IDXGIFactory2 , we can create the IDXGISwapChain that is tied to the
adapter.
Note
The 1 and 2 at the end of IDXGIDevice1 and IDXGIFactory2 differentiate
between the different versions of Direct3D and DXGI that exist. Direct3D 11.1 is
an add-on to Direct3D 11.0, so we need a way to define the different versions.
The same goes for DXGI, which has gone through multiple versions since Vista.
dxgiFactory->CreateSwapChainForCoreWindow(
m_d3dDevice.Get(),
reinterpret_cast<IUnknown*>(window),
&swapChainDesc,
nullptr,
Search WWH ::




Custom Search