From C# code I'm creating Microsoft.UI.Xaml.Controls.SwapChainPanel instance and getting its IntPtr like this:
WinRT.IObjectReference nativeObject = ((IWinRTObject)MySwapChainPanel).NativeObject;
IntPtr panelIntPtr = nativeObject.ThisPtr;
var cli = new MyCliClass();
cli.SetRenderer(panelIntPtr);
And in C++/CLI project I'm trying to use it like this:
#include <d3d11_2.h>
#include <d2d1_2.h>
#include <windows.ui.xaml.media.dxinterop.h>
void TestPlayerCli::MyCliClass::SetRenderer(System::IntPtr swapChainPtr)
{
ISwapChainPanelNative* panelNative;
reinterpret_cast<IUnknown*>(swapChainPtr.ToPointer())->QueryInterface(IID_PPV_ARGS(&panelNative));
//not working either
//panelNative = (ISwapChainPanelNative*)swapChainPtr.ToPointer();
IDXGISwapChain2* m_swapChain;
//init m_swapChain code...
HRESULT hr = panelNative->SetSwapChain(m_swapChain);
}
What would be the proper way to get ISwapChainPanelNative object from provided swapChainPtr in this case?
For WinUI3 you need to #include <microsoft.ui.xaml.media.dxinterop.h> rather than <windows.ui.xaml.media.dxinterop.h>.