tags:

views:

66

answers:

3

I want to program for DirectX in C# and i have DirectX SDK, what kind of project should be choose ? Windows form or ....

+2  A: 

You should use XNA, that is the replacement for Managed DirectX C#

Microsoft XNA ('XNA's Not Acronymed) is a set of tools with a managed runtime environment provided by Microsoft that facilitates computer game development and management. XNA attempts to free game developers from writing "repetitive boilerplate code" and to bring different aspects of game production into a single system.

From Wikipedia XNA Article.

Unless you want to just render windows but WPF might be the best options. See this blog post.

David Basarab
+3  A: 

You should ask yourself first: What's the purpose of my project?

If you intend to building applications with beautiful 2D-3D visuals, then you just need to learn WPF.

On the other hand, if you wanna build games that require a lot of resources, XNA is the way to go.

Building applications on XNA is a lot of pain, since XNA is built for gaming. The same can be said about building games with WPF.

In both cases, you don't need to communicate natively with DirectX (Which could be done via C++). Unless you're building a low level rendering engine, or a (very) high budget game.

SiN
+1  A: 

XNA:

XNA is a game oriented framework that allow you to target multiple hardware easily (Windows, the Xbox 360, Zune and now Windows Phone 7 with version 4) using .NET languages like C#.

Note that there's not a 1-1 relation between XNA and the DirectX SDK, for instance, it doesn't expose D3D10 or D3D11 or some interfaces that you can find in D3DX.

.NET Wrappers:

If your are looking for something similar than the native DirectX API, you have 3 options:

  • Windows® API Code Pack for Microsoft® .NET Framework: wraps a bunch of Windows native libraries such as DirectX so they can be used from managed code. Note it doesn't expose API's prior to D3D10 such as D3D9.

  • SlimDX: Same thing but only for DirectX and exposes Direct3D from version 9 to 11 (SlimDX is an aside project that is not related to Microsoft).

  • C++/CLI and DIY the wrapper: Unless you have special needs, I wouldn't recommend it.

The final choice depends on your needs. If it's just for learning purpose of the DirectX API but in C#, I would say pick the Windows API Code Pack or SlimDX.

Stringer Bell
XNA is the replacement for Managed DirectX C#. See here http://msdn.microsoft.com/en-us/library/bb197956.aspx and http://blogs.msdn.com/b/al_msft/archive/2006/03/20/555065.aspx MDX2 was folded into XNA
David Basarab
Hi David, thanks for the links. Sure you're indeed right it's a replacement in terms of product placement/marketing. But you can't deny that API Code Pack/SlimDX are more close to native DirectX than XNA is, since they are just wrappers. In similar way MDX1.1 and MDX2 have been wrappers for DX9 back in the days.
Stringer Bell
The XNA team said that XNA is not meant to "Replace" MDX, it just so happens that MDX was discontinued so that the team could focuson XNA. XNA and MDX are quite different in thier goals.
Neil N