DirectX from C# [closed]
Asked Answered
S

1

11

I'm looking into various options for using DirectX in C#; ideally I want to use whatever technology is preferred by Microsoft.

Non-Microsoft Technologies:

Microsoft Technologies:

Rationale behind the technology I want to use:

  • I want a code-first framework (as opposed to writing XAML in WPF)
  • I want (ideally) a Microsoft supported framework that isn't deprecated
  • I want to build applications that don't over-rely on 3rd party dependencies (i.e. If I was to build an application with WPF, the framework will likely already be installed on the users machine as part of the .NET framework)

Questions:

  • What is Microsoft's prefered method for writing DirectX exabled applications (aside from WPF)?
  • What dangers are there in using deprecated technologies (MDX, XNA)?
  • What is the most popular non-Microsoft DirectX technology that can be used from C#?
Selsyn answered 24/10, 2014 at 7:53 Comment(9)
SlimDX hasn't been touched in years according to github. SharpDX seems actively maintained. SharpDX also has a D2D wrapper.Vital
@thumbmunkeys, unfortunately neither are Microsoft technologies :-(Selsyn
yes, but I don't think there is a "preferred Microsoft method", it really depends on your use case. SharpDX is a largely autogenerated DirectX wrapper, so it stays close to the original API (great, because the exisiting C++ DirectX documentation applies). It seems it will also be upgraded to support DirectX 12: sharpdx.org/news/sharpdx-next I have used it and highly recommend it.Vital
Regarding the question #2 I can tell you that XNA will no longer be supported, so don't use it.Pursuant
That is strange, there are rumours going around that XNA4.5 is coming. msxna.codeplex.com/releases/view/112067Hakenkreuz
That Codeplex project is some one's pet project and is not an official Microsoft project.Detached
BTW, there was also the "Windows 7 API Code Pack" but it's disappeared from the Microsoft sites.Detached
As I understood, sharp dx was moved to xenko, with all the sharp dx codebase, currently it called stride, available with nugget and also you can try it out with new vvvv gamma visualprogramming.net stride3d.netSpoilfive
As mentioned by comments on the answer, all of these libraries listed in this question are dead, and the SlimDX website is down, but the github repo is still herePedaiah
D
10

The DirectX technology is central to modern Windows presentation and game graphics, so there's lots of different avenues to it. Your question doesn't really state what kind of application you are building or what platform you are trying to target.

Managed DirectX 1.1 has a long list of issues at this point: it doesn't support .NET 4.x which means VS 2010 or later C# projects by default can't use it. It uses legacy D3DX9 and legacy DirectSetup deployment. It does not support 64-bit native apps. It only supports Direct3D 9 and not Direct3D 10.x or 11.x. It exposes a bunch of legacy stuff like DirectPlay and DirectSound. It hasn't been updated since ~2006 and finding samples for it is a challenge. It does not support Windows Store apps, Windows phone, Xbox 360, or Xbox One.

SlimDX is a good choice for someone who has an existing Managed DirectX 1.1 application who wants to move to something a bit better supported. It is compatible with x64 native apps and .NET 4.0. The project has indeed stalled in terms of progression, but it's open source so you can always work with it yourself.

XNA Game Studio 4 supports .NET 4.0 and can target Xbox 360, Windows phone 7, Windows phone 8 (in appcompat), and Windows 32-bit apps. It does not support x64 native apps, and the content pipeline is only compatible with VS 2010. It uses legacy D3DX9 so it depends on the deprecated DirectSetup deployment. It exposes Direct3D 9 and not Direcxt3D 10.x or 11.x. It does not support Windows Store apps or Xbox One. It's specific to writing games.

Windows Presentation Foundation has Direct3D9/Direct3D9Ex interop, but not Direct3D 10.x or Direct3D 11.x. This is a useful technology for Win32 desktop apps, but is not supported for Windows Store apps, Windows phone, or Xbox One. See MSDN. It's not particularly suited to making games, but many game developers have used it for their tools pipeline. The lack of DirectX 10.x/11.x support is challenging, but you could make it work with DXGI Shared Surfaces with Direct3D9Ex.

Note that there is a GitHub project WPF DX11 interop that can be helpful here.

SharpDX is a popular choice for a C# mapping of the modern DirectX APIs. It also supports Windows Store and Windows Phone apps, and is an active project.

BTW, If you are just looking for a direct way to use Direct2D from C# you may want to look at Win2D.

See DirectX and .NET

Detached answered 24/10, 2014 at 17:55 Comment(1)
SharpDX is no longer active, consigning C# + DirectX to the grave as far as I'm concerned (outside of professional engines). Microsoft's only recommended method that I've heard recently is to wrap DirectX as a Window Runtime Component. But why haven't we seen any major endeavors to do that? Maybe just because SharpDX has done the job? Or is it because that's not a realistic solution? I don't know. SharpDX is stable and very useable, it's the absolutely best solution currently to use DX11 from C#, if you consider using an unsupported library acceptable.Occultism

© 2022 - 2024 — McMap. All rights reserved.