views:

6326

answers:

4

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?

+23  A: 

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.

Soviut
Thanks for this Soviut.
Stu Andrews
+7  A: 
  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.
Robert MacLean
Um, what? XNA -is- a wrapper.
TraumaPony
No it's not - see http://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.
Robert MacLean
+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 ...
Pop Catalin
+14  A: 

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.

paulecoyote
A: 

"The industry" is firmly set in the camp of unmanaged C++ with DirectX (or OpenGL), and shows no sign of migrating to a new language. However, other languages are gaining popularity in niche areas such as portable platforms, web games, etc.

Kylotan
XNA is not a new language, its a platform.
Soviut
It's not clear what point you are trying to make here. You can call XNA a platform if you like but it's essentially a framework for game development using C# and the industry in general is neither moving towards C# with XNA or C# independent of XNA.
Kylotan