Skip to main content
gamedev.net
🔒 Locked

Help!BackBuffer!

Started by knight_xie 0 replies 1k views
Original Post
knight_xie
knight_xie
HI! I want to save backbuffer to an image ,i try with the code bellow.but it doesn''t work.why? HRESULT hr; RECT SrcRect; D3DLOCKED_RECT d3dlr; g_lpBackBuffer->LockRect(&d3dlr,NULL,NULL); D3DXSaveSurfaceToFile("2.bmp",D3DXIFF_BMP ,g_lpBackBuffer,NULL,NULL); g_lpBackBuffer->UnlockRect();
eFoDay
eFoDay
you shouldnt need to lock the back buffer
here is the code I use and it seems to work fine


void CDirect3D::TakeScreenShot(LPCTSTR pDestFile)
{
D3DDISPLAYMODE displayMode;

LPDIRECT3DSURFACE9 pd3dsFront = NULL;

// Get the display mode

m_pd3dDevice->GetDisplayMode(0, &displayMode);

// Create a surface to hold the front buffer

m_pd3dDevice->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height,
D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pd3dsFront, NULL);

// Get the front buffer and save it to a file

if( SUCCEEDED( m_pd3dDevice->GetFrontBufferData(0, pd3dsFront) ) )
D3DXSaveSurfaceToFile(pDestFile, D3DXIFF_BMP, pd3dsFront, NULL, NULL);

// Release the surface

if( pd3dsFront ) pd3dsFront->Release();
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.