Created
June 13, 2012 07:23
-
-
Save vinjn/2922506 to your computer and use it in GitHub Desktop.
Fastest method of screen capturing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void dump_buffer() | |
{ | |
IDirect3DSurface9* pRenderTarget=NULL; | |
IDirect3DSurface9* pDestTarget=NULL; | |
const char file[] = "Pickture.bmp"; | |
// sanity checks. | |
if (Device == NULL) | |
return; | |
// get the render target surface. | |
HRESULT hr = Device->GetRenderTarget(0, &pRenderTarget); | |
// get the current adapter display mode. | |
//hr = pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddisplaymode); | |
// create a destination surface. | |
hr = Device->CreateOffscreenPlainSurface(DisplayMde.Width, | |
DisplayMde.Height, | |
DisplayMde.Format, | |
D3DPOOL_SYSTEMMEM, | |
&pDestTarget, | |
NULL); | |
//copy the render target to the destination surface. | |
hr = Device->GetRenderTargetData(pRenderTarget, pDestTarget); | |
//save its contents to a bitmap file. | |
hr = D3DXSaveSurfaceToFile(file, | |
D3DXIFF_BMP, | |
pDestTarget, | |
NULL, | |
NULL); | |
// clean up. | |
pRenderTarget->Release(); | |
pDestTarget->Release(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment