本文整理汇总了C++中IDirect3DDevice9::GetBackBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DDevice9::GetBackBuffer方法的具体用法?C++ IDirect3DDevice9::GetBackBuffer怎么用?C++ IDirect3DDevice9::GetBackBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DDevice9
的用法示例。
在下文中一共展示了IDirect3DDevice9::GetBackBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBackBufferPixels
////////////////////////////////////////////////////////////////
//
// CScreenGrabber::GetBackBufferPixels
//
//
//
////////////////////////////////////////////////////////////////
bool CScreenGrabber::GetBackBufferPixels ( uint uiSizeX, uint uiSizeY, CBuffer& buffer, SString& strOutError )
{
HRESULT hr;
// Try to get the back buffer
IDirect3DSurface9* pD3DBackBufferSurface = NULL;
hr = m_pDevice->GetBackBuffer ( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pD3DBackBufferSurface );
if ( FAILED( hr ) )
{
strOutError = SString( "GetBackBuffer failed (0x%08x)", hr );
return false;
}
// Adjust/create screenshot target size
if ( !m_pScreenShotTemp || m_pScreenShotTemp->m_uiSizeX != uiSizeX || m_pScreenShotTemp->m_uiSizeY != uiSizeY )
{
// Delete old one if it exists
SAFE_RELEASE( m_pScreenShotTemp );
// Try to create new one if needed
if ( uiSizeX > 0 )
m_pScreenShotTemp = CGraphics::GetSingleton ().GetRenderItemManager ()->CreateRenderTarget ( uiSizeX, uiSizeY, false, true );
}
if ( !m_pScreenShotTemp )
{
strOutError = "No ScreenShotTemp";
return false;
}
// Copy back buffer into our private render target
D3DTEXTUREFILTERTYPE FilterType = D3DTEXF_LINEAR;
hr = m_pDevice->StretchRect( pD3DBackBufferSurface, NULL, m_pScreenShotTemp->m_pD3DRenderTargetSurface, NULL, FilterType );
if ( FAILED( hr ) )
{
strOutError = SString( "StretchRect failed (0x%08x)", hr );
return false;
}
// Clean up
SAFE_RELEASE( pD3DBackBufferSurface );
if ( !m_pScreenShotTemp->ReadPixels ( buffer, strOutError ) )
{
dassert( !strOutError.empty() );
return false;
}
return true;
}