I'm experimenting with D3D11 for fun. I can create a device and swap chain, RTV, DSV, and get them all working fine. Now in my D3D9 framework I have the capability to change display modes on the fly, and switch fullscreen etc, so I wanted to replicate this functionality in D3D11. (My laptop is rather old and only DirectX 9.0c capable, but D3D11 works through the feature levels).
Here's the code I use to (try to) enumerate display modes and display them in the console output
// Create DXGI factory, enum display modes
IDXGIFactory* pFactory = NULL;
CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&pFactory);
IDXGIAdapter* pAdapter;
for (int i = 0; true; i++)
{
HRESULT enumhr = pFactory->EnumAdapters(i, &pAdapter);
if (DXGI_ERROR_NOT_FOUND == enumhr || FAILED(enumhr) || NULL == pAdapter)
{
break;
}
DXGI_ADAPTER_DESC adapterDesc;
pAdapter->GetDesc(&adapterDesc);
if (pAdapter)
{
char data[256] = { 0 };
wcstombs(data, adapterDesc.Description, 256);
std::cout << "Found adapter: " << std::endl;
std::cout << " Name: " << data << std::endl;
std::cout << " System Memory: " << adapterDesc.DedicatedSystemMemory << std::endl;
std::cout << " Dedicated Memory: " << adapterDesc.DedicatedVideoMemory << std::endl;
std::cout << " Shared Memory: " << adapterDesc.SharedSystemMemory << std::endl;
std::cout << std::endl;
I'm reasonably certain that your second call to GetDisplayModeList also needs the pNumModes param - at least that's the way I do it and it works fine (and is also consistent with the sample code given in the documentation).
Here's my full code: void D3D11Vid_EnumerateModes (void)
{
IDXGIFactory *pFactory = NULL;
IDXGIAdapter *pAdapter = NULL;
I learned Pascal back in university in 1988 - I wouldn't care if I never saw camel casing ever again. ;)
The only remaining reason why I can think you're not getting any modes is because your adapter doesn't support any modes in the format you're using. Which would be very odd indeed, but it might be worth trying other formats to see what you get back.
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.
But.. that can't be right, because I can create the device and render out triangles (with D3D_FEATURE_LEVEL_9_3), and exactly the same back buffer format!