17
\$\begingroup\$

I want to start off developing for my Xbox 360, and I've heard of the XNA framework that can target both the PC and Xbox. This sounds like an attractive option since my clients can use the game/app on normal computers as well.

However I'm very new to the Xbox scene. Is XNA only for hobbyist development, and is it not recommended for semi-professional or corporate application development? Does XNA lack the capabilities of a C++ developed solution, or dos it badly reduce performance of a game/app running on the Xbox?

Is it possible to target the Xbox using C#, and without XNA? What are the advantages?

Low-level programming would be in C++ directly working with DirectX. What are the advantages?

\$\endgroup\$

3 Answers 3

15
\$\begingroup\$

The short answer: Yes.

XNA is just a tool. It is suitable for all but the most processor- and graphically-intensive games. If you are considering XNA for an Xbox 360 game, here's what you will miss out on:

  • Access to the SIMD/Vector unit for doing really, really fast CPU floating point maths
  • Ability to use native language code that will probably be a little bit faster than C#
  • Ability to be a little bit lazier with how you allocate memory
  • XBLIG games have access to only 4 of the 6 cores (but we still get all 3 CPUs, and they're not full cores either, so we don't miss out on much) - not sure if this applies to non-XBLIG XNA games
  • Full DirectX access for doing really obscure graphical trickery

There might be more - this is off the top of my head.

(Speculation: if you are a professional developer (as in: have a devkit), I think that you can use XNA with native code, same as P/Invoke on Windows. Best of both worlds. You'd have to ask Microsoft. See also XDK.)

The bottom line is that an XNA game is almost as fast as a native game and can do almost as much stuff. I'd suggest you use it unless you find a compelling reason not to.

I do not know if there is any kind of managed DirectX for the 360. Perhaps SlimDX is a good place to start.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ What is "XBLIG"? \$\endgroup\$
    – Ricket
    Oct 28, 2010 at 12:21
  • 2
    \$\begingroup\$ Xbox live indie game \$\endgroup\$
    – dotminic
    Oct 28, 2010 at 12:50
  • \$\begingroup\$ There are only 3 cores, and we have access to all of them. You don't get access to 2 threads. One of those threads is for XNA, the other is a thread that no one gets access to when making games, as it is for the XBOX OS. \$\endgroup\$
    – Olhovsky
    Apr 3, 2011 at 18:55
  • 1
    \$\begingroup\$ Also you don't get to be lazy with memory allocation. Except for very simple games, you have to pool all objects (which involves an allocate/free type model -- no better than C++) to prevent expensive garbage collections on the .NET compact CLR, which uses a generational collection approach. \$\endgroup\$
    – Olhovsky
    Apr 3, 2011 at 18:56
12
\$\begingroup\$

Unless you are willing to pay $10,000 for an XBOX or Playstation devkit, then the only console you can develop for is the XBOX 360, and the only way you can do it is with XNA.

For professional development, unless you really need to get 100% of the processing power of the XBOX (which most games, especially 2D games do not need), then XNA in my opinion is actually much better for development.

Some mistakes that other answerers have made:

The XBOX has only 3 cores. You get access to all of them with XNA.

Each core has hyperthreading and support for 2 hyperthreads. You only get access to 4/6 threads. One of those threads is for XNA. The other is a thread that no game developers get access to, as it is used by the XBOX OS.

C# on the XBOX is much slower than C# on Windows. The XBOX uses the .NET compact CLR, which is very lightweight and lacks many of the desktop CLR's optmizations. The XBOX security features prevent programs from modifying their own source code. This makes it very difficult to even allow .NET code to run, much less to run fast. Part of what makes managed code competitive in performance with C++ native code, is that the CLR can modify it's own code to optimize cache coherency. The XNA dev team has to jump through some pretty big hoops just to get C# to run on the XBOX at all, and there is an associated performance cost with these hoops.

You don't get to be TOO lazy with memory allocation. XNA on Windows greatly simplifies memory allocation, as you'd expect from a managed environment. However, on the XBOX, the .NET compact CLR uses a sweep & compact approach to garbage collection, and the typical approach to preventing stuttering in your game due to collections, is to avoid collections altogether. This requires using object pools for your classes, and using structs for smaller objects, where you'd normally uses classes in the Windows environment. Object pooling generally requires an allocate/free model of object management, which is no worse (and maybe a little bit better) than C++ memory management.

That said, development in C#/XNA is still many times faster and easier than development in C++ without a DirectX API (which XNA is).

Here's the status of a game I'm making in XNA, after 4 weeks of work:

Screenshot of game after 4 weeks of development.

That should give you a sense of how incredibly fast development with the XNA library/API is in combination with C#.

That screenshot is rendered by the XBOX at about 65FPS.

If you're a hobbyist game developer, and you want to make games for a console, not only is XNA+XBOX your only realisitic option, it's also a pretty amazing option, a fun development environment, and many XBOX Live Arcade games have been made with XNA, and made hundreds of thousands of dollars doing it. (Limbo for example.)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ One of the clearest answers I've had about XNA dev. Thank you. \$\endgroup\$
    – keyle
    Jun 18, 2012 at 4:13
4
\$\begingroup\$

XNA is a double-edged blade; it's relatively easy to use, but very extensible and customizable. The problem is, being based on a managed language and having a so-so Compact Framework implementation, squeezing some performance from a complex game can be very painful and frustrating.

You can only deploy to your Xbox via C#/XNA, or via C++/DirectX, but the second option requires qualifying for a XBLA license and paying for the devkit, which can be very expensive (~10000$).

And remember that the Xbox is a closed system. Forget any direct TCP/IP interaction, you can only communicate with other consoles present in the Xbox Live! network, and you can't do raw HTTP connections.

So, if you are thinking of a game, give XNA a try and move to a devkit if you need more raw power (and you have the money). If you are thinking of an application... just target for another platform.

\$\endgroup\$
3
  • \$\begingroup\$ I wonder how different XNA and the devkit are... \$\endgroup\$
    – Spooks
    Oct 28, 2010 at 13:43
  • \$\begingroup\$ XNA is a high-level, C# API. A devkit is a special console where you can deploy games written with C++ and DirectX, thus having a lower level access and better performance overall. \$\endgroup\$
    – r2d2rigo
    Oct 28, 2010 at 13:55
  • \$\begingroup\$ so.. completely different \$\endgroup\$
    – Spooks
    Oct 28, 2010 at 16:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .