我正在遵循教程,并将通常的初始化转换为使用 ComPtrs 直到这一行:
ID3D11Device* g_pd3dDevice = nullptr;
ID3D11Device1* g_pd3dDevice1 = nullptr;
// Obtain the Direct3D 11.1 versions if available
hr = g_pd3dDevice->QueryInterface( __uuidof( ID3D11Device1 ), reinterpret_cast<void**>( &g_pd3dDevice1 ) );
这是我期望的直接模拟:
Microsoft::WRL::ComPtr<ID3D11Device> device = nullptr;
Microsoft::WRL::ComPtr<ID3D11Device1> device1 = nullptr;
// Obtain the Direct3D 11.1 versions if available
hr = device->QueryInterface(__uuidof(ID3D11Device1), reinterpret_cast<ID3D11Device1**>(&device1));
有许多编译器和智能感知警告(对我来说真的很神秘)。它不喜欢强制转换,也不喜欢我使用 QueryInterface() 的方式。
我应该做什么?
Errors:
Error 1 error C2440: 'reinterpret_cast' : cannot convert from 'Microsoft::WRL::Details::ComPtrRef<Microsoft::WRL::ComPtr<ID3D11Device1>>' to 'ID3D11Device1 **'
Error 2 error C2660: 'Microsoft::WRL::Details::RemoveIUnknownBase<T>::QueryInterface' : function does not take 1 arguments
智能感知警告(可能有帮助吗?):
18 IntelliSense: function "Microsoft::WRL::Details::RemoveIUnknownBase<T>::QueryInterface [with T=ID3D11Device]" (declared at line 64 of "C:\Program Files (x86)\Windows Kits\8.1\Include\winrt\wrl/client.h") is inaccessible
使用时ComPtr
,你应该使用::As
方法而不是QueryInterface
。例如,hr = device.As(&device1);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)