Is it possible to make a screen capture of a DirectX application (game for exemple) in D3D11 ?
I can do it easily in DirectX 9 or with API hooking (IDXGISwapChain::Present), but impossible with DirectX 11.
I initalize D3D11 and create the SwapChain with the Game window (FindWindow()), then I get the BackBuffer,
then ID3D11Texture2D::GetDesc() to use it in ID3D11Device::CreateTexture2D(), then ID3D11DeviceContext::CopyResource() which gives me a new ID3D11Texture2D resource.
When I save it with usual ways like D3DX11SaveTextureToFile(), I always get a Black image.
What did I forget ?
Thanks.
I think here are two-step to check your code:
ID3D11DeviceContext::CopyResource() does it work as expected? As we know, this func require strictly same desc of src and des, is src tex have some diff desc from des tex. you can output to a window directly to check before you save.
D3DX11SaveTextureToFile is deprecated, which is replaced by SaveToXXXFile (where XXX is WIC, DDS, or TGA; WIC doesn't support DDS and TGA; D3DX 9 supported TGA as a common art source format for games). DirectXTex and DirectXTK library is new. But it still works now if you config appropriate. check this func return value. Make sure you do know how to use