本文整理汇总了C++中IDXGISwapChain::GetDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGISwapChain::GetDevice方法的具体用法?C++ IDXGISwapChain::GetDevice怎么用?C++ IDXGISwapChain::GetDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDXGISwapChain
的用法示例。
在下文中一共展示了IDXGISwapChain::GetDevice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDevice
HRESULT STDMETHODCALLTYPE CDXGISwapChainDWM::GetDevice(REFIID riid, void **ppDevice)
{
return m_pSwapChain->GetDevice(riid, ppDevice);
}
示例2: SwapPresentHook
HRESULT STDMETHODCALLTYPE SwapPresentHook(UINT syncInterval, UINT flags)
{
IDXGISwapChain *swap = (IDXGISwapChain*)this;
if(lpCurrentSwap == NULL && !bTargetAcquired)
{
lpCurrentSwap = swap;
SetupD3D11(swap);
bTargetAcquired = true;
}
if(lpCurrentSwap == swap)
{
ID3D11Device *device = NULL;
HRESULT chi;
if(SUCCEEDED(chi = swap->GetDevice(__uuidof(ID3D11Device), (void**)&device)))
{
if(!lpCurrentDevice)
{
lpCurrentDevice = device;
oldD3D11Release = GetVTable(device, (8/4));
newD3D11Release = ConvertClassProcToFarproc((CLASSPROC)&D3D11Override::DeviceReleaseHook);
SetVTable(device, (8/4), newD3D11Release);
}
ID3D11DeviceContext *context;
device->GetImmediateContext(&context);
if(!bHasTextures && bCapturing)
{
if(dxgiFormat)
{
if(!hwndReceiver)
hwndReceiver = FindWindow(RECEIVER_WINDOWCLASS, NULL);
if(hwndReceiver)
{
D3D11_TEXTURE2D_DESC texDesc;
ZeroMemory(&texDesc, sizeof(texDesc));
texDesc.Width = d3d11CaptureInfo.cx;
texDesc.Height = d3d11CaptureInfo.cy;
texDesc.MipLevels = 1;
texDesc.ArraySize = 1;
texDesc.Format = dxgiFormat;
texDesc.SampleDesc.Count = 1;
texDesc.Usage = D3D11_USAGE_STAGING;
texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
bool bSuccess = true;
UINT pitch;
for(UINT i=0; i<2; i++)
{
HRESULT ching;
if(FAILED(ching = device->CreateTexture2D(&texDesc, NULL, &d3d11Textures[i])))
{
bSuccess = false;
break;
}
if(i == 0)
{
ID3D11Resource *resource;
if(FAILED(d3d11Textures[i]->QueryInterface(__uuidof(ID3D11Resource), (void**)&resource)))
{
bSuccess = false;
break;
}
D3D11_MAPPED_SUBRESOURCE map;
if(FAILED(context->Map(resource, 0, D3D11_MAP_READ, 0, &map)))
{
bSuccess = false;
break;
}
pitch = map.RowPitch;
context->Unmap(resource, 0);
resource->Release();
}
}
if(bSuccess)
{
d3d11CaptureInfo.mapID = InitializeSharedMemory(pitch*d3d11CaptureInfo.cy, &d3d11CaptureInfo.mapSize, ©Data, textureBuffers);
if(!d3d11CaptureInfo.mapID)
bSuccess = false;
}
if(bSuccess)
{
bHasTextures = true;
d3d11CaptureInfo.captureType = CAPTURETYPE_MEMORY;
d3d11CaptureInfo.hwndSender = hwndSender;
d3d11CaptureInfo.pitch = pitch;
d3d11CaptureInfo.bFlip = FALSE;
PostMessage(hwndReceiver, RECEIVER_NEWCAPTURE, 0, (LPARAM)&d3d11CaptureInfo);
}
else
//.........这里部分代码省略.........