相关疑难解决方法(0)

使用DirectX捕获屏幕

我知道如何使用GDI捕获屏幕,但它很慢(它几乎没有捕获10 fps)

我已经读过DirectX提供最佳速度.但在我开始学习DirectX之前,我想测试一个样本,看看它是否真的那么快.

我发现这个问题提供了一个示例代码来执行此操作:

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 …
Run Code Online (Sandbox Code Playgroud)

c++ directx winapi

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

directx ×1

winapi ×1