本文整理汇总了C++中IDXGIFactory::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIFactory::QueryInterface方法的具体用法?C++ IDXGIFactory::QueryInterface怎么用?C++ IDXGIFactory::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDXGIFactory
的用法示例。
在下文中一共展示了IDXGIFactory::QueryInterface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSwapChain
egl::Error DXGISwapChainWindowSurfaceWGL::createSwapChain()
{
egl::Error error = setObjectsLocked(false);
if (error.isError())
{
return error;
}
if (mRenderbufferBufferHandle)
{
mFunctionsWGL->dxUnregisterObjectNV(mDeviceHandle, mRenderbufferBufferHandle);
mRenderbufferBufferHandle = nullptr;
}
// If this surface is bound to a texture, unregister it.
bool hadBoundSurface = (mTextureHandle != nullptr);
if (hadBoundSurface)
{
mFunctionsWGL->dxUnregisterObjectNV(mDeviceHandle, mTextureHandle);
mTextureHandle = nullptr;
}
IDXGIFactory *dxgiFactory = GetDXGIFactoryFromDevice(mDevice);
if (dxgiFactory == nullptr)
{
return egl::Error(EGL_BAD_NATIVE_WINDOW, "Failed to query the DXGIFactory.");
}
IDXGIFactory2 *dxgiFactory2 = nullptr;
HRESULT result = dxgiFactory->QueryInterface(__uuidof(IDXGIFactory2),
reinterpret_cast<void **>(&dxgiFactory2));
if (SUCCEEDED(result))
{
ASSERT(dxgiFactory2 != nullptr);
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
swapChainDesc.BufferCount = 1;
swapChainDesc.Format = mSwapChainFormat;
swapChainDesc.Width = static_cast<UINT>(mWidth);
swapChainDesc.Height = static_cast<UINT>(mHeight);
swapChainDesc.Format = mSwapChainFormat;
swapChainDesc.Stereo = FALSE;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage =
DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT | DXGI_USAGE_BACK_BUFFER;
swapChainDesc.BufferCount = 1;
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL;
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
swapChainDesc.Flags = mSwapChainFlags;
result = dxgiFactory2->CreateSwapChainForHwnd(mDevice, mWindow, &swapChainDesc, nullptr,
nullptr, &mSwapChain1);
SafeRelease(dxgiFactory2);
SafeRelease(dxgiFactory);
if (FAILED(result))
{
return egl::Error(EGL_BAD_ALLOC, "Failed to create swap chain for window, result: 0x%X",
result);
}
mSwapChain = mSwapChain1;
mSwapChain->AddRef();
}
else
{
DXGI_SWAP_CHAIN_DESC swapChainDesc = {};
swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Format = mSwapChainFormat;
swapChainDesc.BufferDesc.Width = static_cast<UINT>(mWidth);
swapChainDesc.BufferDesc.Height = static_cast<UINT>(mHeight);
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferUsage =
DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT | DXGI_USAGE_BACK_BUFFER;
swapChainDesc.Flags = mSwapChainFlags;
swapChainDesc.OutputWindow = mWindow;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Windowed = TRUE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
result = dxgiFactory->CreateSwapChain(mDevice, &swapChainDesc, &mSwapChain);
SafeRelease(dxgiFactory);
if (FAILED(result))
{
return egl::Error(EGL_BAD_ALLOC, "Failed to create swap chain for window, result: 0x%X",
result);
}
}
ID3D11Texture2D *colorBuffer = nullptr;
result = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D),
reinterpret_cast<void **>(&colorBuffer));
if (FAILED(result))
{
return egl::Error(EGL_BAD_ALLOC, "Failed to query texture from swap chain, result: 0x%X",
//.........这里部分代码省略.........
示例2: QueryInterface
HRESULT STDMETHODCALLTYPE CDXGIFactoryDWM::QueryInterface(REFIID riid, void **ppvObj)
{
return m_pFactory->QueryInterface(riid, ppvObj);
}
示例3: mkScopeGuard
IDXGISwapChain1 * DX11::CreateSwapChain (HWND hwnd)
{
IDXGISwapChain1 * chain = nullptr;
IDXGIDevice * dxgiDevice = nullptr;
HRESULT hr = m_pd3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void **)& dxgiDevice);
scope_guard_t on_exit_dxgid = mkScopeGuard(std::mem_fun(&IDXGIDevice::Release), dxgiDevice);
if (!SUCCEEDED(hr))
{
TRACE_MSG(LL_ERROR, CTX_BB | CTX_GFX | CTX_INIT, "DX11 device QueryInteface for dxgi device failed, hresult=0x%x", hr);
on_exit_dxgid.Dismiss();
return nullptr;
}
IDXGIAdapter * dxgiAdapter = nullptr;
hr = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void **)& dxgiAdapter);
scope_guard_t on_exit_dxgia = mkScopeGuard(std::mem_fun(&IDXGIDevice::Release), dxgiAdapter);
if (!SUCCEEDED(hr))
{
TRACE_MSG(LL_ERROR, CTX_BB | CTX_GFX | CTX_INIT, "cannot find parent of dxgi device, hresult=0x%x", hr);
on_exit_dxgia.Dismiss();
return nullptr;
}
IDXGIFactory * dxgiFactory = nullptr;
hr = dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void **)& dxgiFactory);
scope_guard_t on_exit_dxgif = mkScopeGuard(std::mem_fun(&IDXGIDevice::Release), dxgiFactory);
if (!SUCCEEDED(hr))
{
TRACE_MSG(LL_ERROR, CTX_BB | CTX_GFX | CTX_INIT, "cannot find parent of dxgi adapter, hresult=0x%x", hr);
on_exit_dxgif.Dismiss();
return nullptr;
}
IDXGIFactory2 * dxgiFactory2 = nullptr;
hr = dxgiFactory->QueryInterface(__uuidof(IDXGIFactory2), reinterpret_cast<void**>(&dxgiFactory2));
scope_guard_t on_exit_dxgif2 = mkScopeGuard(std::mem_fun(&IDXGIDevice::Release), dxgiFactory2);
if (SUCCEEDED(hr))
{
// This system has DirectX 11.1 or later installed, so we can use this interface
DXGI_SWAP_CHAIN_DESC1 stSwpChainDesc = { 0 };
stSwpChainDesc.Width = 0;
stSwpChainDesc.Height = 0;
stSwpChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
stSwpChainDesc.Stereo = false;
stSwpChainDesc.SampleDesc.Count = 1;
stSwpChainDesc.SampleDesc.Quality = 0;
stSwpChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
stSwpChainDesc.BufferCount = 1; // Used to be 1
stSwpChainDesc.Scaling = DXGI_SCALING_STRETCH;
stSwpChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
stSwpChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
hr = dxgiFactory2->CreateSwapChainForHwnd(m_pd3dDevice, hwnd, &stSwpChainDesc, nullptr, nullptr, &chain);
dxgiFactory2->Release();
}
else
{
// This system only has DirectX 11.0 installed
TRACE_MSG(LL_ERROR, CTX_BB | CTX_GFX | CTX_INIT, "cannot find DXGIFactory2 interface, hresult=0x%x", hr);
on_exit_dxgif2.Dismiss();
//dxgiFactory->CreateSwapChain( /* parameters */);
}
TRACE_MSG(LL_INFO, CTX_BB | CTX_GFX | CTX_INIT, "Created DX11 swap chain @ 0x%x for hwnd=0x%x", chain, hwnd);
return chain;
}