1

Just encountered strange problem when trying to get available display modes. Let me explain...

At first, I enumerate available adapters and push then to std::vector and this works fine:

for(UINT i = 0; pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++i)
    vAdapters->push_back(pAdapter);

Then I populate combobox with these adapters and allow to select one I want to use.

When I try to enumerate outputs and get available display modes, first I get selected adapter from combobox:

IDXGIAdapter* pSelectedAdapter = (*vAdapters)[index];

I checked address of selected adapter, and it matches with obtained one during enumeration of adapters.

Then, trying to enumerate outputs and get their description:

IDXGIOutput* pOutput;
DXGI_OUTPUT_DESC *odesc = 0;
for(UINT i = 0; pSelectedAdapter->EnumOutputs(i, &pOutput) != DXGI_ERROR_NOT_FOUND; ++i)
{
    pOutput->GetDesc(odesc);
}

And there is the problem. Loop finds my two monitors and returns pOutput pointer for all of them, but when I try to fire GetDesc(odesc), odesc is not returned. It looks like pOutput pointer is pointing to... empty object. Enumerating available display modes results in 0 available modes, no matter which back buffer format I want to check modes for.

Thanks, Patryk

Patryk Lipski
  • 163
  • 10

2 Answers2

2

You're passing in a null pointer to GetDesc when it's expecting a pointer to a DXGI_OUTPUT_DESC structure. Try below:

IDXGIOutput* pOutput;
DXGI_OUTPUT_DESC odesc;
for(UINT i = 0; pSelectedAdapter->EnumOutputs(i, &pOutput) != DXGI_ERROR_NOT_FOUND; ++i)
{
    pOutput->GetDesc(&odesc);
}
Adam Miles
  • 3,504
  • 17
  • 15
  • Yeah, I already realized that. Also solved problem with no display modes available. I was polling for DXGI_FORMAT_R32G32B32A32_FLOAT back buffer format, which resulted in 0 display formats. Enumerating for R8G8B8A8_UNORM did the trick. – Patryk Lipski Apr 26 '15 at 16:35
-2

Also remember to Release the IDXGIOutput or you'll have a memory leak: See here.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
Fheavr
  • 1