Answered by:
How to convert Microsoft::WRL::ComPtr<ID3D11Device> into ID3D11Device* ? (C++/CX app win 8 )

Question
-
How to convert Microsoft::WRL::ComPtr<ID3D11Device> into ID3D11Device* ? (C++/CX app win 8 )
Because I want to save DirectX image byCaptureTexture( ID3D11Device* pDevice, ID3D11DeviceContext* pContext, ID3D11Resource* pSource, ScratchImage& result ).
Below my variables :
Microsoft::WRL::ComPtr<ID3D11Device> m_d3dDevice;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_d3dContext;
Microsoft::WRL::ComPtr<ID3D11Texture2D> depthStencil;Monday, January 27, 2014 7:19 AM
Answers
-
Anytime you need a 'raw' pointer from a ComPtr, just use .Get()
ScratchImage img; hr= CaptureTexture( m_d3dDevice.Get(), m_d3dContext.Get(), depthStencil.Get(), img);
Two comments:
* Using DirectXTex for just capturing a screenshot or dumping a texture to disk is overkill. That's exactly what the ScreenShot module is designed to do very efficiently. See <http://blogs.msdn.com/b/chuckw/archive/2012/05/04/direct3d-11-textures-and-block-compression.aspx>
* It's a little odd to be dumping a 'depth stencil buffer' and the resulting DDS file is unlikely to be viewable by most DDS file viewers.
- Proposed as answer by Chuck Walbourn - MSFTMicrosoft employee Monday, January 27, 2014 7:31 AM
- Edited by Chuck Walbourn - MSFTMicrosoft employee Monday, January 27, 2014 7:55 AM
- Marked as answer by KC-Steven Monday, January 27, 2014 8:07 AM
Monday, January 27, 2014 7:31 AM -
You would create a new ScratchImage of the target size, then DirectXTex's CopyRectangle to copy cropped image data from your img to the new one.
For DirectXTex library specific questions, you should go to the CodePlex site.
- Proposed as answer by Chuck Walbourn - MSFTMicrosoft employee Wednesday, January 29, 2014 6:53 AM
- Edited by Chuck Walbourn - MSFTMicrosoft employee Wednesday, January 29, 2014 7:05 AM
- Marked as answer by KC-Steven Wednesday, January 29, 2014 7:27 AM
Wednesday, January 29, 2014 6:53 AM
All replies
-
Anytime you need a 'raw' pointer from a ComPtr, just use .Get()
ScratchImage img; hr= CaptureTexture( m_d3dDevice.Get(), m_d3dContext.Get(), depthStencil.Get(), img);
Two comments:
* Using DirectXTex for just capturing a screenshot or dumping a texture to disk is overkill. That's exactly what the ScreenShot module is designed to do very efficiently. See <http://blogs.msdn.com/b/chuckw/archive/2012/05/04/direct3d-11-textures-and-block-compression.aspx>
* It's a little odd to be dumping a 'depth stencil buffer' and the resulting DDS file is unlikely to be viewable by most DDS file viewers.
- Proposed as answer by Chuck Walbourn - MSFTMicrosoft employee Monday, January 27, 2014 7:31 AM
- Edited by Chuck Walbourn - MSFTMicrosoft employee Monday, January 27, 2014 7:55 AM
- Marked as answer by KC-Steven Monday, January 27, 2014 8:07 AM
Monday, January 27, 2014 7:31 AM -
Thanks you help.
Monday, January 27, 2014 8:08 AM -
But My DirectX is in XAML. like below
I builded it by SurfaceImageSource.
So, I can also use the screenshot?Monday, January 27, 2014 8:25 AM -
"ScreenShot" is just a light-weight version of "CaptureTexture + Save*ToFile" combined.Monday, January 27, 2014 7:28 PM
-
You say right. To input depthStencil pointer is odd. I had altered. thank you!Tuesday, January 28, 2014 3:05 AM
-
Hi,I have a new problem.
I had gotten a ScratchImage img.
But I want to crop it. How to do it?
- Edited by KC-Steven Wednesday, January 29, 2014 6:48 AM
Wednesday, January 29, 2014 6:45 AM -
You would create a new ScratchImage of the target size, then DirectXTex's CopyRectangle to copy cropped image data from your img to the new one.
For DirectXTex library specific questions, you should go to the CodePlex site.
- Proposed as answer by Chuck Walbourn - MSFTMicrosoft employee Wednesday, January 29, 2014 6:53 AM
- Edited by Chuck Walbourn - MSFTMicrosoft employee Wednesday, January 29, 2014 7:05 AM
- Marked as answer by KC-Steven Wednesday, January 29, 2014 7:27 AM
Wednesday, January 29, 2014 6:53 AM -
Thank you! Next,I will post the problem in there.Wednesday, January 29, 2014 7:30 AM