I am working with DXGI and DirectX 11 using C++. At the moment I experimenting with IDXGIFactory. After some research and reading the documentation I noticed there are different versions.
IDXGIFactory IDXGIFactory1 IDXGIFactory2 IDXGIFactory3 IDXGIFactory4 IDXGIFactory5
But I also noticed that there are only methods for creating such an instance for the first 3 IDXGIFactory versions but not for the last 3.
CreateDXGIFactory CreateDXGIFactory1 CreateDXGIFactory2
There is no CreateDXGIFactory3, CreateDXGIFactory4 or CreateDXGIFactory5.
So my question is how to create an IDXGIFactory5 instance?
Furthermore I am wondering if I cannot instantiate an instance of IDXGIFactory5 myself how I can force D3D11CreateDevice to create and use an IDXGIFactory5 internally so I can retrieve an reference from the resulting ID3D11Device?
EDIT:
OK now I understand the different CreateDXGIFactory functions and how to create an IDXGIFactory5 instance. But after understanding this I got the next problem. The documentation from IDXGIAdapter2 says I should use IDXGIFactory1::EnumAdapters1 to query an instance. But looking at the function signature I am only getting an IDXGIAdapter1.
HRESULT EnumAdapters1(
UINT Adapter,
[out] IDXGIAdapter1 **ppAdapter
);
How do I enumerate IDXGIAdapter2 instances?
The numbers on CreateDXGIFactory
are related in changes to the signature of that function, not to the interfaces implemented by the returned COM object. In particular, CreateDXGIFactory2
added the Flags
parameter.
You would obtain a reference to the desired interface in the same way as any other COM object. Either:
Pass the IID of the desired interface as riid
, then cast the returned object to that interface OR
Pass the IID of an interface such as IUnknown
. Call QueryInterface
on the returned object to obtain the desired interface. This might be useful if you want to support several versions, as you could try version 5 and if that is not found fall back to version 4, for example.
For example, option 1 might look like:
IDXGIFactory2* factory;
HRESULT hr = CreateDXGIFactory2(0, IID_IDXGIFactory5, (void**)&factory);
if(SUCCEEDED(hr))
{
// ...
}