From 4b2a9db74e1d273bc0804d01c6e144191e49b270 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 5 Jun 2023 12:37:11 -0500 Subject: [PATCH] Add 'capture' --- capture | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 capture diff --git a/capture b/capture new file mode 100644 index 0000000..98e2d29 --- /dev/null +++ b/capture @@ -0,0 +1,34 @@ +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(); +} \ No newline at end of file