Last week we had a huge Microsoft representation at Eurogamer ranging from Xbox360, XboxOne, Windows Phone and Windows 8 demonstrating our devcies, services and latest titles. During the event I had a lots of interesting discussions with game devs, educators and students, one of the key themes of discussion was what is the best technology to build my games with?
To address this I think you need to look at the industry and some best practices, hands down Unity is now by far the most popular middleware and what we are seeing is right now some real platform and service differentiators.
One of the cool factor about Win 8 is XAML and its support for D3D11. However one of the key debates from existing Windows Silverlight developers is which skills do I need to learn, my simply comment is if we are given a choice I would suggest that you with go with XAML/C# and this where some great open source project come in such as MonoGame which I have spoken a lot about in the past on this blog and SharpDx.
I know for many games devs building for Windows 8 they have spent a lot of time seeing if there was a way to combine D3D11 and XAML. I would simply say stop searching and start focusing on doing XAML with some DirectX immediate mode rendering.
The following is a simply walkthrough of how to do some DirectX immediate mode rendering in your C#/XAML app using the SharpDx library. This isnt a new subject and one the original MSDN Blog was published on exactly this, Combining XAML and DirectX. The blog is an excellent starting point and talks about what is possible with DirectX and XAML.
So what is SharpDx
SharpDx is a very thin library that exposes the DirectX api’s for use in C# WinRT apps. SharpDx exposes the DirectX API’s nearly 1-to-1 with no higher level abstraction (like what XNA is).
SharpDX is FREE
You can simply use the SharpDx library to render DirectX content in your XAML/C# apps via the controls mentioned in Combining XAML and DirectX (SurfaceImageHost & SwapChainBackgroundPanel) nt.
I’ll spend this post walking you through how to get this all setup.
Step 1 : Get SharpDx
Current stable version of SharpDX is 2.5.0.
SharpDX binaries are directly downloadable from this web site or available from nuget packages.
SharpDX is now bundled into 2 separate packages, for all platforms and .NET Framework:
There is also a Visual Studio Extension available with Project Templates for the Toolkit. Search for SharpDX in Extension Manager in VisualStudio 2012 and install it from there
Step 3 : Build SharpDx code
firstname.lastname@example.org:sharpdx/SharpDX.git // use https://github.com/sharpdx/SharpDX.git if you don't have a github account
Step 4 : Using these DirectX-C# libraries to render islands of DirectX in your XAML (SurfaceImageSource)
The SharpDx team have some great samples that show how to use these libraries to render DirectX content in your XAML surface via the SurfaceImageSource element.
The 2 “Rectangle” elements below are “Filled” with the SurfaceImageSource DirectX rendered content.
The d3dRectangle will load the SurfaceImageSource content generated via the Direct3D pipeline
The d2dRectangle will load the SurfaceImageSource content generated via the Direct2D pipeline.
This demo shows both pipelines for rendering content,
This rendered surface is just bitmap content so you can mix XAML all over or under it at your convenience!
Step 5 : Using these DirectX-C# libraries to render full page DirectX under your XAML (SwapChainBackgroundPanel)
This second sample shows how to render a FULL screen DirectX surface underneath XAML using the SwapChainBackgroundPanel.
Without going into too much detail the SwapChainBackgroundPanel lets you render DirectX content underneath your XAML content, because the XAML content sits within the SwapChainBackgroundPanel as a child.
Let me know how you get on and what interesting games or apps you end up building with SharpDx.