![](/img/trans.png)
[英]How exactly am I supposed to use the ID3DXFont interface? (Direct3D 11, c++)
[英]How do I use a Direct3D 11 pointer wrapped in ComPtr to get a 11.1 interface?
我正在關注教程,並且我已經將通常的初始化轉換為使用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()。
我該怎么辦?
錯誤:
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.