Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DirectX from C# [closed]

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:

  • SharpDX
  • Slim DX
  • Direct2D Manager Wrapper

Microsoft Technologies:

  • WPF
  • DirectX 9.0 for managed code (deprecated)
  • XNA Framework (deprecated)

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#?
like image 235
Matthew Layton Avatar asked Oct 24 '14 07:10

Matthew Layton


1 Answers

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

like image 98
Chuck Walbourn Avatar answered Oct 11 '22 17:10

Chuck Walbourn