Reputation: 1
The code I am using is C++ for DirectX 11 if this has some relevance.
I am using code that I have been taught to use. The thing is the class that calls my graphics methods has:
Microsoft::WRL::ComPtr<ID3D11Device>
This does not work with some of my methods though. They take:
ID3D11Device*
Upvotes: 0
Views: 1255
Reputation: 41127
To convert Microsoft::WRL::ComPtr<T>
to a T*
pointer, use the Get method.
using Microsoft::WRL::ComPtr;
ComPtr<ID3D11Device> device;
hr = D3D11CreateDevice( ..., device.GetAddressOf(), ... );
if (FAILED(hr))
// error
...
SomeFunction(device.Get());
See this wiki and Microsoft Docs.
Some older COM smart-pointers automatically converted to
T*
through an operator, but this is actually a problematic behavior which is why C++ Standard smart-pointers likestd::unique_ptr<>
useget.()
for conversion to a raw pointer. For use of->
or[]
, the operator overloads take care of it. See this article for more details.
Upvotes: 2