Comparison between XNA and DirectX (C#)
Asked Answered
I

4

50

In terms of PC development (excluding Xbox and 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)?

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

Where is the industry moving in terms of game programming?

Izolaiztaccihuatl answered 5/2, 2009 at 7:8 Comment(0)
H
54

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 plenty of performance, both for 2D and 3D game development.

Here is a good Channel 9 video where 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.

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.

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.

Halfblood answered 5/2, 2009 at 7:12 Comment(0)
F
30

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.

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.

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.

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# 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.

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.

Flak answered 5/2, 2009 at 8:55 Comment(3)
"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." I know it's a few years later but this post still gets a lot of views, XNA draw calls are about 6 times slower than SharpDX calls and 4 time slower than slimdx calls: code4k.blogspot.co.uk/2011/03/…Sodomite
well that seems like decent proof :) Good link @STRAIGHTOUTTACOMPTONFlak
@STRAIGHTOUTTACOMPTON Note to googlers: Update 2012/05/15: Note that the original code was fine tuned to a particular config and may not give you the same results. I have rewritten this sample to give more accurate and predictible results. Comparison with XNA was also not fair and inaccurate, you should have something like x4 slower instead of x9. SharpDX latest version 2.1.0 is also x1.35 slower than C++ now. An update of this article will follow on new sharpdx.org websiteValoniah
J
17
  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.
Jea answered 5/2, 2009 at 8:29 Comment(3)
Um, what? XNA -is- a wrapper.Cleora
No it's not - see xnarocks.spaces.live.com/blog/cns!CDFDED0A2593C8E1!172.entry if you need clarification on it. Just to give a quick example wrapper 1:1 function mapping. How does the pipeline stuff in XNA 2.0 map to DirectX? It doesn't. It's not a wrapper.Jea
+1, XNA is a higher level managed code game library written on top of DirectX. For lot's o things it doesn't even use DirectX classes/structures but rolls it's own, most notably matrices, vectors, and some others ...Government
Y
5

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 benchmarked against XNA, SlimDX and the windows API code pack.

Yawp answered 6/3, 2012 at 16:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.