How about this code
void dump_buffer()
{
IDirect3DSurface9* pRenderTarget=NULL;
IDirect3DSurface9* pDestTarget=NULL;
const char file[] = "Pickture.bmp";
// Verify that it is OK.
if (Device == NULL)
return;
// Obtained render target
HRESULT hr = Device->GetRenderTarget(0, &pRenderTarget);
// Obtained current adapter display mode
//hr = pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddisplaymode);
// Create destination surface
hr = Device->CreateOffscreenPlainSurface(DisplayMde.Width,
DisplayMde.Height,
DisplayMde.Format,
D3DPOOL_SYSTEMMEM,
&pDestTarget,
NULL);
// Copy render target to destination surface
hr = Device->GetRenderTargetData(pRenderTarget, pDestTarget);
// Save to bitmap file
hr = D3DXSaveSurfaceToFile(file,
D3DXIFF_BMP,
pDestTarget,
NULL,
NULL);
// Clean up before exiting
pRenderTarget->Release();
pDestTarget->Release();
}
© 2024 OneMinuteCode. All rights reserved.