C# 在 Visual Studio 2012 中使用 DirectX

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12835847/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 00:37:15  来源:igfitidea点击:

Using DirectX with Visual Studio 2012

c#visual-studio-2012sdkwindows-8directx

提问by Radek Wyroslak

I have some DirectX projects written in C# that I need to run via Visual Studio 2012 specifically.

我有一些用 C# 编写的 DirectX 项目,我需要专门通过 Visual Studio 2012 运行它们。

All of these projects use the namespace called, "Microsoft.DirectX".

所有这些项目都使用名为“Microsoft.DirectX”的命名空间。

Microsoft Windows SDK installed completely and successfully on my Windows 8 computer, however this namespace is still unrecognised.

Microsoft Windows SDK 在我的 Windows 8 计算机上完全成功地安装,但是这个命名空间仍然无法识别。

My question is, "How do I run and develop DirectX apps using a combination of C#, Visual Studio 2012 and MS Windows SDK?"

我的问题是,“我如何使用 C#、Visual Studio 2012 和 MS Windows SDK 的组合运行和开发 DirectX 应用程序?”

采纳答案by Beachwalker

I would recommend you to have a look at SharpDX. This is a thin managed access to DirectX and the API is very similar to the unmanaged version (SharpDX is automatically built from the unmanaged c++ header files). AFAIK this is currently the fastest managed aproach to use DirectX.

我建议你看看SharpDX。这是对 DirectX 的精简托管访问,API 与非托管版本非常相似(SharpDX 是从非托管 C++ 头文件自动构建的)。AFAIK 这是目前使用 DirectX 的最快的管理方法。

A very important thing might be the fact that you are able to develop Win8-Metro-Apps, too. AFAIK this is not possible/allowed with every other lib. I mentioned this because you wrote you want to develop on/for Win8 but you didn't said what kind of app. Metro-Apps has some more restrictions than Desktop-Apps for Win8.

一件非常重要的事情可能是您也可以开发 Win8-Metro-Apps。AFAIK 这对于其他所有库都是不可能的/不允许的。我提到这个是因为你写了你想在/为Win8开发,但你没有说什么样的应用程序。Metro-Apps 比 Win8 的桌面应用程序有更多的限制。

Managed DirectX is out of date as already mentioned. But it seems that XNA is also not longer maintained since the release of the last version 4. So you are stuck if you want to use modern DX10 or DX11 because XNA uses DX9. An alternative here is the ANX framework. This project is currently in an early development stage but seems promising to me. ANX can use DirectX for rendering and uses SharpDX in this case. In contrast to XNA (which is strongly related to only DirectX9) SharpDX has the ability to use other renderers, too (e.g. OpenGL for Linux).

如前所述,托管 DirectX 已过时。但似乎自上一个版本 4 发布以来,XNA 也不再维护。因此,如果您想使用现代 DX10 或 DX11,您就会陷入困境,因为 XNA 使用 DX9。这里的另一种选择是ANX 框架。该项目目前处于早期开发阶段,但对我来说似乎很有希望。在这种情况下,ANX 可以使用 DirectX 进行渲染并使用 SharpDX。与 XNA(仅与 DirectX9 密切相关)相比,SharpDX 也具有使用其他渲染器的能力(例如 Linux 的 OpenGL)。

回答by Nasreddine

Managed DirectX is obsolete and no longer maintained by Microsoft as it is being replaced by XNA. Last version to support Managed DirectX was thisone (February 2010 release).

Managed DirectX 已经过时并且不再由 Microsoft 维护,因为它正在被XNA取代。支持托管 DirectX 的最后一个版本是这个版本(2010 年 2 月发布)。

You can also give SlimDXa try :

你也可以试试SlimDX

SlimDX is a free open source framework that enables developers to easily build DirectX applications using .NET technologies such as C#, VB.NET, and IronPython. It is designed to be an efficient, simple, and lean wrapper that fully encompasses all of Microsoft's gaming and multimedia technologies and exposes them to managed code. All of the code is under the MIT/X11 license, and all content is under the Creative Commons Attribution-Share Alike license. Our latest release is March 2011, and can be found for users and developers on the Download page.

SlimDX 是一个免费的开源框架,它使开发人员能够使用 C#、VB.NET 和 IronPython 等 .NET 技术轻松构建 DirectX 应用程序。它旨在成为一个高效、简单和精益的包装器,它完全包含 Microsoft 的所有游戏和多媒体技术,并将它们公开给托管代码。所有代码均在 MIT/X11 许可下,所有内容均在知识共享署名-相同方式共享许可下。我们的最新版本是 2011 年 3 月,用户和开发人员可以在下载页面上找到。

回答by bitbonk

You will probably need Microsoft XNA.

您可能需要Microsoft XNA