Capturar tela usando o DirectX
Eu sei como usar o GDI para capturar a tela, no entanto, é muito lento (apenas captura 10 fps)
Eu li que o DirectX oferece a melhor velocidade. Mas antes de começar a aprender o DirectX, eu queria testar uma amostra para ver se é realmente tão rápido.
Eu encontrei issoPergunta, questão que oferece um código de exemplo para fazer isso:
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();
}
Eu tentei incluir os arquivos necessários. No entanto, nem todos eles podem ser incluídos (por exemplo,#include <D3dx9tex.h>
)
Alguém pode fornecer um exemplo de trabalho que possua todas as informações necessárias ou me indicar quais bibliotecas devo instalar.
Estou usando o Visual C ++ 2010 Express no Windows 7 Ultimate (x64).
Editar:
Além disso, este código não está completo, por exemplo, qual é oDevice
identificador ?!