IDXGIFactory :: CreateSwapChain()返回E_NOINTERFACE?

时间:2013-03-29 00:05:13

标签: c++ com directx-11 hresult

在我在DirectX11中设计的渲染器中,我需要能够随时创建交换链,但是我使用的方法在CreateSwapChain()调用时崩溃:

    IDXGIDevice * device;
    HR(d3ddevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&device));

    IDXGIAdapter * adapter;
    HR(device->GetParent(__uuidof(IDXGIAdapter), (void**)&adapter));

    IDXGIFactory * factory;
    HR(adapter->GetParent(__uuidof(IDXGIAdapter), (void**)&factory));

    IDXGISwapChain* swapChain = 0;
    HR(factory->CreateSwapChain(_device->GetContent(), &description, &swapChain));

d3ddevice是一个指向ID3D11Device的指针,完全初始化了一切,我测试了它。 description是一个DXGI_SWAP_CHAIN_DESC结构,每个字段都填写完毕。但是,该函数返回E_NOINTERFACE。我的系统支持着色器模型5 / directx 11

1 个答案:

答案 0 :(得分:4)

当您查询IDXGIAdapter时,您正在使用IDXGIFactory的UUID:

IDXGIFactory * factory;
HR(adapter->GetParent(__uuidof(IDXGIAdapter), (void**)&factory));

尝试将其更改为_uuidof(IDXGIFactory)