mirror of https://github.com/axmolengine/axmol.git
31 lines
490 B
C
31 lines
490 B
C
|
#pragma once
|
||
|
|
||
|
#include <Unknwn.h>
|
||
|
#include <wrl/client.h>
|
||
|
|
||
|
namespace MFUtils
|
||
|
{
|
||
|
|
||
|
template <typename _Ty>
|
||
|
using TComPtr = Microsoft::WRL::ComPtr<_Ty>;
|
||
|
|
||
|
template <typename _Ty>
|
||
|
inline TComPtr<_Ty> MakeComInstance()
|
||
|
{
|
||
|
TComPtr<_Ty> obj;
|
||
|
_Ty** ppv = &obj;
|
||
|
*ppv = new _Ty();
|
||
|
return obj;
|
||
|
}
|
||
|
|
||
|
template <typename _Ty>
|
||
|
inline TComPtr<_Ty> ReferencedPtrToComPtr(_Ty* ptr)
|
||
|
{
|
||
|
TComPtr<_Ty> obj;
|
||
|
_Ty** ppv = &obj;
|
||
|
*ppv = ptr;
|
||
|
return obj;
|
||
|
}
|
||
|
|
||
|
} // namespace MFUtils
|