Closed mediabuff closed 3 years ago
The samples on directx-sdk-legacy-samples are basically the same source code that shipped in the legacy DirectX SDK. Those samples didn't make use of any COM smartpointer and generally used the SAFE_RELEASE
macro style. These were written back in the VS .NET 2003 / VS 2005 timeframe.
For directx-sdk-samples and my various GitHub libraries (DirectXTex, DirectXTK, DirectXMesh, etc.) I've used WRL::ComPtr
. The main value of this COM smartpointer is:
The ATL CComPtr is older, but actually is not as ubiquitous. The ATL component is optional with modern Visual Studio, so it's not there by default. Back in the VS 2012 days, ATL wasn't in the Express SKUs.
The only real down-side of WRL::ComPtr
is it is conflated with Windows Runtime so some people think it won't work on Window 7 desktop, and the slightly older C++ style.
Requiring C++/WinRT is not an option because the current generation GDK no longer uses Windows Runtime API design.
The WIL option is problematic because it's not included in any of these platform SDKs.
I hate the idea of having to create another smart-pointer, but something truly stand-alone is needed for my usage cases.
For completeness, there's also a half-hearted
_com_ptr_t
in Visual Studio, but it's barely "smart".
See this wiki page.
thanks for your detailed response.
1) >> something truly stand-alone is needed for my usage cases.
You may consider: https://github.com/AlexBAV/moderncom.
Or the emerging win32::com_ptr https://github.com/microsoft/cppwin32/blob/dd6eece980c1fe9074d932794485ff336d8490f3/cppwin32/base.h
2) Any reason you did'nt consider extending the usage of wrl:comptr with directx-sdk-legacy-samples
3) >>current generation GDK no longer uses Windows Runtime API design.
Could you please expand further ?
Is there a possibility of moving all directx samples - current and new - use winrt::com_ptr or wil::com_ptr ?