I would like to use DX10 and DXGI to capture a desktop image in Windows 7. However, when I call GetDisplaySurfaceData, I get an error DXGI_ERROR_INVALID_CALL. The code snippet is as following:
D3D10_TEXTURE2D_DESC d3d10Texture2DDesc; D3D10_TEXTURE2D_DESC desc; ZeroMemory( &desc, sizeof(desc) ); desc.Width = 1440; desc.Height = 900; desc.MipLevels = 1; desc.ArraySize = 1; desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; desc.SampleDesc.Count = 1; desc.Usage = D3D10_USAGE_DYNAMIC; desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE|D3D10_CPU_ACCESS_WRITE; ID3D10Texture2D *pD3d10Texture = NULL; hr = g_pd3dDevice->CreateTexture2D( &desc, NULL, &pD3d10Texture ); hr = pD3d10Texture->QueryInterface(__uuidof(IDXGISurface), (void**)&g_pDXGISurface); hr = g_pOutput->GetDisplaySurfaceData(g_pDXGISurface);
In fact, my first question above all is if it's possible to use this DXGIOutput::GetDisplaySurfaceData function to capture the desktop. In DX9 we have GetFrontBufferData, but in DX10/11 there doesn't seem to be a replacement.
Please help and any input would be greatly appreciated.