尝试使用SharpDX和DXD11获取对Windows App SDK C#中SwapChainPanel的本机COM对



我正在尝试使用SharpDX获取对在Windows App SDK C#中创建的SwapChainPanel的本机COM对象的引用。

我将我的项目从UWP迁移到了带有WinUI 3和.Net 6的更新的Windows应用程序SDK,除了创建SwapChainPael之外,一切都正常。

UWP:https://github.com/CanTalat-Yakan/UWP-GameEngineEditor/blob/main/Editor/Views/View_Port.xaml.cshttps://github.com/CanTalat-Yakan/UWP-GameEngineEditor/blob/main/Editor/Assets/Engine/Utilities/Engine_Renderer.cs

新的Windows应用程序SDK:https://github.com/CanTalat-Yakan/3D_Engine-WinUI3/blob/main/WinUI3DEngine/WinUI3DEngine/WinUI3DEngine/UserControls/ViewPort.xaml.cshttps://github.com/CanTalat-Yakan/3D_Engine-WinUI3/blob/main/WinUI3DEngine/WinUI3DEngine/WinUI3DEngine/Assets/Engine/Utilities/CRenderer.cs

上述错误的部分是这个CRender:71(ctor(

// Obtain a reference to the native COM object of the SwapChainPanel.
using (var nativeObject = ComObject.As<DXGI.ISwapChainPanelNative2>(m_SwapChainPanel))
nativeObject.SwapChain = m_SwapChain;

异常详细信息:

SharpDX.SharpDXException HResult=0x80004002消息=HResult:[0x80004002],模块:[通用],ApiCode:[E_NOINTERFACE/No such支持接口],消息:不支持

Source=SharpDX StackTrace:位于SharpDX.Result.CheckError((位于的SharpDX.ComObject.QueryInterface(Guid-Guid,IntPtr和outPtr(SharpDX.ComObject.QueryInterfaceT位于SharpDX.ComObject.As[T](对象ComObject(位于WinUI3DEngine.Assets.Engine.Utilities.CRender.ctor(交换链面板_swapChainPanel(,位于D:\Misc\Sourcetree\Engine\WinUI3DEngine\WinUI 3DEngine\Assets\Engine\Utilities \CRenderer.cs:line71在WinUI3DEngine.Assets.Engine.CEngine.ctor(SwapChainPanel_swapChainPanel,TextBlock_TextBlock(,位于D:\Misc\Sourcetree\Engine\WinUI3DEngine\WinUI 3DEngine\Assets\Engine\CEngine.cs:line18在WinUI3DEngine.UserControls.ViewPort.Initialize(Object sender,中的RoutedEventArgs e(D: \Misc\Sourcetree\Engine\WinUI3DEngine\WinUI 3DEngine\UserControls\ViewPort.xaml.cs:line41 atWinRT_EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.b_1_0(对象发件人,RoutedEventArgs e(位于ABI.Microsoft.UI.Xaml.RoutedEventHandler。<gt;c_DisplayClass10_0。<Do_Abi_Invoke>b__0(路由事件处理程序invoke(在WinRT.ComWrappersSupport.MarshallDelegateInvoke[T](IntPtrthisPtr,操作`1调用(ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_ABI_Invoke(IntPtr thisPtr,IntPtr发送器,IntPtr e(

我从流程的一开始就尝试了调试,每件事都类似于UWP版本。使用新的Windows应用程序SDK,Windows.UI.Xaml.Controls的命名空间更改为Microsoft.UI.Xaml.Controls我对SharpDX包装不太了解,但这可能是问题所在吗?也许SharpDX根本不支持.Net 5或6,仅支持4及以下版本?我需要以不同的方式设置设备-Contex和SwapchainPanel的创建吗?

如果我得到了一个解决方案,如果是我的错误或其他,我会把它们张贴在下面

基本

windows.ui.xaml.media.dxtinterop::ISwapChainPanelNative,可与UWP windows.ui.xaml.Controls.SwapChainPanel控件配合使用

不起作用

WinUI3 Microsoft.UI.Xaml.Controls.SwapChainPanel控件,它实现了一个不同的接口,该接口具有相同的名称,但有一个新的GUID(63aad0b8-7c24-40ff-85a8-640d944cc325(和命名空间:Microsoft.UI.Xaml.media.dxinterop::ISwapChainPonelNative

注意Windows与Microsoft的命名空间差异https://githubhot.com/repo/amerkoleci/Vortice.Windows/issues/91

这里有一个变通方法:https://github.com/amerkoleci/Vortice.Windows/discussions/164

但由于SharpDX被取消作用,我切换到了更新的包装器Vorticehttps://github.com/amerkoleci/Vortice.Windowshttps://github.com/amerkoleci/Vortice.Windows/tree/main/src

它支持WinUI 3和新的Windows应用程序SDK(新项目重聚(

相关内容

  • 没有找到相关文章

最新更新