来自C#的DirectX [英] DirectX from C#

查看:486
本文介绍了来自C#的DirectX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究在C#中使用DirectX的各种选项;理想情况下,我想使用Microsoft首选的任何技术。

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

非微软技术公司:

  • SharpDX
  • Slim DX
  • Direct2D Manager Wrapper

Microsoft Technologies:

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

我要使用的技术背后的理论依据:


  • 我想要一个代码优先的框架(与在WPF中编写XAML相对)

  • 我想要(理想情况下)一个不被弃用的Microsoft支持的框架

  • 我想要构建不过度依赖第三方依赖关系的应用程序(即如果我要使用WPF构建应用程序,则该框架可能已经作为.NET框架的一部分安装在用户计算机上)

问题:


  • Microsoft编写DirectX兼容应用程序(除WPF之外)的首选方法是什么? / li>
  • 使用不赞成使用的技术(MDX,XNA)有什么危险?

  • 可以从以下哪种最流行的非Microsoft DirectX技术中使用? C#?

推荐答案

DirectX技术是现代Windows演示文稿和游戏图形的核心,因此有很多不同的途径。您的问题并没有真正说明您正在构建哪种类型的应用程序或您试图针对的平台。

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 具有一个此时的问题列表很长:它不支持.NET 4.x,这意味着默认情况下VS 2010或更高版本的C#项目无法使用它。它使用旧版D3DX9和旧版DirectSetup部署。它不支持64位本机应用程序。它仅支持Direct3D 9,不支持Direct3D 10.x或11.x。它公开了很多传统的东西,例如DirectPlay和DirectSound。自2006年以来一直没有进行过更新,因此要寻找样本是一个挑战。它不支持Windows Store应用程序,Windows Phone,Xbox 360或Xbox One。

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 对于拥有现有的Managed DirectX 1.1应用程序想要迁移到更好的支持。它与x64本机应用程序和.NET 4.0兼容。该项目确实在进度方面停滞了,但是它是开源的,因此您可以随时自己使用它。

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 支持.NET 4.0,并且可以定位到Xbox 360,Windows Phone 7,Windows Phone 8(在appcompat中)和Windows 32位应用程序。它不支持x64本机应用程序,并且内容管道仅与VS 2010兼容。它使用旧版D3DX9,因此取决于不推荐使用的DirectSetup部署。它只显示Direct3D 9,而不显示Direcxt3D 10.x或11.x。它不支持Windows Store应用程序或Xbox One。

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 具有Direct3D9 / Direct3D9Ex互操作性,但没有Direct3D 10.x或Direct3D11.x。这是Win32桌面应用程序的有用技术,但Windows Store应用程序,Windows Phone或Xbox One不支持此技术。请参见 MSDN 。它不是特别适合制作游戏,但许多游戏开发人员已将其用于其工具渠道。缺乏DirectX 10.x / 11.x支持具有挑战性,但是您可以使其与使用Direct3D9Ex的DXGI共享表面

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.


有一个GitHub项目 WPF DX11互操作在这里可能会有所帮助。

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

SharpDX 是现代DirectX API的C#映射的流行选择。它还支持Windows Store和Windows Phone应用程序,并且是一个活动项目。

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,如果您正在寻找直接使用C#中Direct2D的方法,查看 Win2D

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

请参见< a href = https://walbourn.github.io/directx-and-net/ rel = nofollow noreferrer> DirectX和.NET

这篇关于来自C#的DirectX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆