XNA 和 DirectX (C#) 的比较

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/514872/
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-04 06:22:48  来源:igfitidea点击:

Comparison between XNA and DirectX (C#)

c#directxxna

提问by Athena

In terms of PC development (excluding Xbox and Zune),

在PC开发方面(不包括Xbox和Zune),

What is the difference between XNA and C# DirectX? Does C# DirectX have a significant advantage over XNA (in terms of speed, royalties, etc)?

XNA 和 C# DirectX 有什么区别?C# DirectX 是否比 XNA 有显着优势(在速度、版税等方面)?

How are the two compared to the speed unmanaged C++ DirectX?

这两者与非托管 C++ DirectX 的速度相比如何?

Where is the industry moving in terms of game programming?

游戏编程行业的发展方向是什么?

采纳答案by Soviut

If you're actually good at writing unmanaged code, then you'll probably be able to write a faster graphics engine on top of DirectX. However, for the hobbyist, XNA has plentyof performance, both for 2D and 3D game development.

如果您确实擅长编写非托管代码,那么您可能能够在 DirectX 之上编写更快的图形引擎。然而,对于爱好者来说,XNA 有足够的性能,无论是 2D 还是 3D 游戏开发。

Here is a good Channel 9 videowhere they run an XNA-built racing game on Xbox 360. It runs well even at full HD. Several of the XBox Live Arcade games have been developed by the XNA community.

这是一个很好的第 9 频道视频,他们在 Xbox 360 上运行 XNA 构建的赛车游戏。即使在全高清下也能运行良好。XNA 社区开发了一些 XBox Live Arcade 游戏。

As far as C# DirectX, as I recall, Managed DirectX as it was called, is no longer officially supported since XNA basically replaces it. I could be wrong, its been a very long time since I looked at it.

至于 C# DirectX,我记得,它被称为托管 DirectX,不再受到官方支持,因为 XNA 基本上取代了它。我可能是错的,我已经很久没有看过它了。

The performance differences are negligible between XNA and Managed DirectX since, in essence they're the same thing; XNA just has a few convenience bits to reduce the amount of boilerplate code you need to write.

XNA 和 Managed DirectX 之间的性能差异可以忽略不计,因为本质上它们是相同的;XNA 只是有一些方便的位来减少您需要编写的样板代码量。

回答by Robert MacLean

  1. XNA and DirectX are very different implementations to solve the same problem - high performance graphic intensive programming. Both support 2D, 3D, audio and networking components. DirectX is unmanaged only where XNA is managed code.
  2. There is a managed implementation of DirectX which is a wrapper around the DirectX calls but that is not getting updated after the current release so I wouldn't bother with it.
  3. XNA is not a wrapper around unmanaged DirectX. It does use parts of DirectX but it is not a wrapper.
  4. The industry still seems very much set on unmanaged DirectX - I say that because all the major engine companies are still coding in C++, ASM and supporting DirectX (either solely or in conjunction with OpenGL for Linux/Mac versions). The fact Microsoft is "dropping" the DirectX managed wrapper and telling people to rather use XNA shows that is where they are pushing managed developers.
  1. XNA 和 DirectX 是解决同一问题的非常不同的实现 - 高性能图形密集型编程。两者都支持 2D、3D、音频和网络组件。DirectX 仅在 XNA 是托管代码的情况下是非托管的。
  2. 有一个 DirectX 的托管实现,它是 DirectX 调用的包装器,但在当前版本之后没有更新,所以我不会打扰它。
  3. XNA 不是非托管 DirectX 的包装器。它确实使用了 DirectX 的一部分,但它不是包装器。
  4. 该行业似乎仍然非常依赖非托管 DirectX——我这么说是因为所有主要引擎公司仍在使用 C++、ASM 进行编码并支持 DirectX(单独或与 OpenGL 结合用于 Linux/Mac 版本)。Microsoft 正在“放弃” DirectX 托管包装器并告诉人们宁愿使用 XNA 的事实表明,这就是他们推动托管开发人员的地方。

回答by paulecoyote

The Xna Game Studio stuff is focused around solving game centric problems, though I would question any poster that says the performance of the Xna game studio stuff is any worse than managed direct x without seeing some decent metrics.

Xna 游戏工作室的东西专注于解决以游戏为中心的问题,尽管我会质疑任何说 Xna 游戏工作室的东西的性能比管理直接 x 更差的海报,但没有看到一些不错的指标。

An independent group outside of MS have created a project called SlimDx - http://slimdx.mdxinfo.com/If you are writing an application rather than a game (which I expect you are not by the other questions) then that might be worth considering.

MS 之外的一个独立小组创建了一个名为 SlimDx 的项目 - http://slimdx.mdxinfo.com/如果您正在编写应用程序而不是游戏(我希望您不是其他问题)那么这可能是值得的考虑。

The industry still heavily uses C++ for game guts, but there have been successful releases of games written in completely managed code using XNA Game Studio on the community games section of XBox live, and released on the XBox Arcade itself. There should be some interesting stats coming pretty soon about how much people have made on the community games.

该行业仍然大量使用 C++ 来制作游戏内容,但是已经在 XBox live 的社区游戏部分成功发布了使用 XNA Game Studio 以完全托管代码编写的游戏,并在 XBox Arcade 上发布。应该很快就会有一些关于人们在社区游戏中赚了多少的有趣统计数据。

Many full price games use C++ for some, but something like Lua for actual game logic... and Lua is not known for the blazing speed!

许多全价游戏在某些情况下使用 C++,但在实际游戏逻辑中使用 Lua 之类的东西……而 Lua 并不以惊人的速度着称!

C# has a good learning curve and is used by tools programmers in the industry - it would be a useful language to have under your belt. C++ would be a great language to have, but it requires more discipline to create functional code - and gives someone new a lot more rope to hang themselves by. C# can dynamically change and do things like unroll loops at runtime rather than compile time - good C# can be as fast or faster than good readable C++ - but you have to know how to use it. In really tight loops, C++ and Assembler might win out in certain circumstances. Often in games using C++, custom allocators are created with their own memory strategies to try and help fragmentation caused by normal allocators... that kind of thing is dealt with by the CLR in .Net/C# and as long as you program to the garbage collectors strengths (the same that you would have to do with your own C++ implementation) then you do not have to concern yourself with such low level implementation detail in .Net.

C# 具有良好的学习曲线,并且被行业中的工具程序员使用 - 这将是一种有用的语言。C++ 将是一门很棒的语言,但它需要更多的纪律来创建函数式代码 - 并且为新手提供了更多的绳索来吊死自己。C# 可以动态更改并执行诸如在运行时而不是编译时展开循环之类的事情——好的 C# 可以与好的可读的 C++ 一样快或更快——但你必须知道如何使用它。在非常紧凑的循环中,C++ 和汇编程序可能会在某些情况下胜出。通常在使用 C++ 的游戏中,自定义分配器是用自己的内存策略创建的,以尝试帮助由普通分配器引起的碎片……这种事情由 .

If you are looking in to getting in to game development and deciding on a language (which, reading between the lines seems to be where you are going with that line of questioning) then the best language to use is the one where you have a finished project to show at the end of it, be it C++, objective C, C#, Flash, Silverlight, etc. As languages change and go in and out of favour, recruiters often look for proven mastery of different languages - which might mitigate not knowing the one they are currently using - and a portfolio of completed work would do that.

如果您正在考虑进入游戏开发并决定使用一种语言(从字里行间阅读似乎是您对那行提问的方向),那么最好使用的语言是您已经完成的语言项目最后展示,无论是 C++、Objective C、C#、Flash、Silverlight 等。 随着语言的变化和流行,招聘人员通常会寻找对不同语言的熟练掌握 - 这可能会减轻不知道的情况他们目前正在使用的那个——以及一组已完成的工作将做到这一点。

回答by Dave Maff

At the moment, it seems that Microsoft do not plan to support XNA in Metro style apps. An alternative to XNA and the now deprecated "Managed DirectX" is SharpDx. This can be used to create Metro style apps and has been favourably benchmarkedagainst XNA, SlimDX and the windows API code pack.

目前,微软似乎不打算在 Metro 风格的应用程序中支持 XNA。XNA 和现已弃用的“Managed DirectX”的替代品是SharpDx。这可用于创建 Metro 风格的应用程序,并已针对 XNA、SlimDX 和 Windows API 代码包进行了良好的基准测试