UWP and DirectX
Asked Answered
C

2

7

I have a task:

'Second component must be written in C++ and must be a UWP assembly/component that will be used by the First part of the task. It must be a DirectX component that draws to SwapChain with transparent background. The content must be a 2D animation that must be bound to current mouse position. The content must be controllable via set of public methods.

DirectX component must be placed on top of your C# GUI so it will act as overlay. Make it event-transparent overlay, it must not capture any GUI events and otherwise interfere with C# app. Use C# host to send mouse events and content change to DX layer.'

But I have no idea how to combine UWP and DirectX. I already have functioning UWP C# app part and what's next?

I'll be grateful for any responces and ideas.

Crack answered 25/4, 2016 at 12:13 Comment(1)
Look there: unknowncheats.me/forum/c-and-c-/… - there's a simple example of how to write to any region of the directx device. About capturing the mouse events - you need to listen to WM_MOUSE*** types of events in your WinMain function.Wulf
H
1

You need to include a SwapChainPanel or SwapChainBackgroundPanel control into your XAML file. This surface will be used to draw your DirectX content. You have a default uwp sample in Visual C++ Template named DirectX 11 and XAML App. It can help you to understand the plumbing but there is only C++ code on this solution.

Henandchickens answered 25/4, 2016 at 15:46 Comment(2)
They are describing XAML+C# code-behind with a SwapChainPanel or SwapChainBackgroundPanel control which can be rendered to with DirectX. There's no built-in C# support for DirectX, but you can use a 3rd party assembly like SharpDX. The built-in Visual C++ template "DirectX 11 and XAML App (Universal Windows)" does this for C++ code-behind, but there's not a built-in template for C# code-behind combined with DirectX.Gooch
You might want to take a look at Win2D which is a C# wrapper for Direct2D, and in particular the Win2D Samples repository.Gooch
G
1

MonoGame!

It's a game framework, based on XNA4 that works on UWP, among a myriad of other platforms. You can pick apart the samples to learn what you need.

http://www.monogame.net/

Gingergingerbread answered 27/9, 2016 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.