本文整理汇总了C++中IDirect3DDevice9::GetDisplayMode方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DDevice9::GetDisplayMode方法的具体用法?C++ IDirect3DDevice9::GetDisplayMode怎么用?C++ IDirect3DDevice9::GetDisplayMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DDevice9
的用法示例。
在下文中一共展示了IDirect3DDevice9::GetDisplayMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFrontBufferPixels
void CSnapShot::GetFrontBufferPixels(UINT uiSizeX, UINT uiSizeY,unsigned char* buffer)
{
// Get our d3d device
IDirect3DDevice9 * pDevice = g_pCore->GetGraphics()->GetDevice();
// Get our display mode
D3DDISPLAYMODE displayMode;
pDevice->GetDisplayMode(0, &displayMode);
// Create our surface
IDirect3DSurface9 * pSurface = nullptr;
pDevice->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height, SCREEN_SHOT_FORMAT, D3DPOOL_SCRATCH, &pSurface, nullptr);
if(pSurface)
{
pDevice->GetFrontBufferData(0, pSurface);
// Create the client rect
RECT clientRect;
{
POINT clientPoint;
clientPoint.x = 0;
clientPoint.y = 0;
ClientToScreen(*(HWND *)COffsets::VAR_HWnd, &clientPoint);
clientRect.left = clientPoint.x;
clientRect.top = clientPoint.y;
clientRect.right = (clientRect.left + displayMode.Width);
clientRect.bottom = (clientRect.top + displayMode.Height);
}
D3DLOCKED_RECT lockedRect;
HRESULT hr = pSurface->LockRect(&lockedRect, NULL, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK | D3DLOCK_DONOTWAIT);
if(SUCCEEDED(hr))
{
void* pBits = lockedRect.pBits;
UINT ms_ulPitch = lockedRect.Pitch;
for(unsigned int i = 0; i < displayMode.Height; ++i)
memcpy(buffer + (displayMode.Width * 4) * i, (BYTE*)pBits + i * ms_ulPitch, (displayMode.Width * 4));
}
pSurface->UnlockRect();
pSurface->Release();
}
}