[英]How do I use a Direct3D 11 pointer wrapped in ComPtr to get a 11.1 interface?
I'm following tutorials and I've converted the usual initialisation to using ComPtrs up to this line: 我正在关注教程,并且我已经将通常的初始化转换为使用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 ) );
Here's what I expected to be the straight analog: 这就是我所期望的直接模拟:
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));
There's a number of compiler and Intellisense warnings (really cryptic to me). 有很多编译器和智能感知警告(对我来说真的很神秘)。 It doesn't like the cast, and it doesn't like how I'm using QueryInterface().
它不喜欢演员,它不喜欢我如何使用QueryInterface()。
What should I be doing? 我该怎么办?
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
Intellisense Warnings (could be helpful?): 智能感知警告(可能有帮助吗?):
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
When using ComPtr
, you should use the ::As
method instead of QueryInterface
. 使用
ComPtr
,应使用::As
方法而不是QueryInterface
。 For example, hr = device.As(&device1);
例如,
hr = device.As(&device1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.