Mix DirectX 12 and XAML controls in UWP

扶醉桌前 提交于 2019-12-12 04:26:00

问题


I would like to create a UWP app (XAML) with C++/CX and DirectX 12 so that I can mix both XAML controls (things like Grid, buttons...) and DirectX, something like a Level Editor, but I'm struggling to find a way how to initialize DirectX to render inside a specific control (like a Grid).

The basic template and all the other tutorials only show how to do it within the full area of the application. When creating a device resource we set the window where to draw with SetWindow(CoreWindow::GetForCurrentThread());

Is there a way how to create a device resource with hwnd from a xaml control and is there a way how to get hwnd for a specific control?


回答1:


The information in the article DirectX - Using XAML with DirectX and C++ in Windows Store Apps all applies to mixing Direct3D 11 or Direct3D 12 with XAML.

It's not clear why you'd want to write your level editor with DirectX 12. In general DirectX 11 is a much easier-to-use API. Unless you are already hitting the CPU-side performance limits of DirectX 11, it's probably more work than it's worth for a level editor.




回答2:


For further reference, here is an official code example: https://blogs.msdn.microsoft.com/windowsappdev/2012/03/15/combining-xaml-and-directx/



来源:https://stackoverflow.com/questions/39681961/mix-directx-12-and-xaml-controls-in-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!