I know how to use GDI to capture screen, however it is very slow (it barely captures 10 fps)
I have read that DirectX offers the best speed. But before I start learning DirectX I wanted to test a sample to see if it is really that fast.
I have found this question that offers a sample code to do that:
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();
}
I have tried to include the required files. However not all of them can be included (for example #include <D3dx9tex.h>).
Can anyone provide a working example that has all of the required includes or point me to what libraries I should install.
I am using Visual C++ 2010 Express on Windows 7 Ultimate (x64).
Edit:
Also, this code is not complete, for example what is the Device identifier?!
Aucun commentaire:
Enregistrer un commentaire