5
\$\begingroup\$

I decided to learn to program in DirectX yesterday, and, not being a huge C++ fanatic, went looking for a .Net wrapper. After reading about SlimDX and SharpDX, I decided I liked what the SharpDX people were doing and began trying to use it. Although they have a huge number of samples that are really nice, I had trouble finding any tutorials specifically for it. I ended up seeing a huge number of C++ tutorials. Besides the really long and less than aesthetically pleasing function names, it really didn't seem any more complicated than using the managed wrappers.

So my options (and what I think about them) are:

  • SlimDX/SharpDX are in a language I am familiar with, but nearly as complicated as the C++
  • DirectX is C++, something I am not too familiar with. I would really need to learn proper memory management.
  • Focus on really learning C++ well before diving into game programming with straight Direct3D. This would allow me to learn proper memory management and get comfortable with C++.

My original thinking was that if using Direct3D was just as easy as a managed equivalent, there would be no point starting with the managed equivalent. On the other hand, if the managed equivalent is much easier, it would allow me to focus on the ins and outs of developing a game rather than constantly worrying about the language and getting even small things done.

So, will using one of these managed wrappers be easier than using the native Direct3D API itself?

\$\endgroup\$
13
  • 2
    \$\begingroup\$ It totally doesn't make sense to ask whether to use SharpDX/SlimDX or DirectX. That's becaus SharpDX/SlimDX are thin wrappers around DirectX. They expose almost exact same API as native C++ API to managed world. It's like asking - do you drive to work automobile or Honda. \$\endgroup\$ Jan 29, 2012 at 21:18
  • 1
    \$\begingroup\$ Also, there isn't really such a thing as "proper memory management" in a language-agnostic sense. There is the kind of memory/resource management you have to do in C++, and there is the kind you have to do in C# (just because you have a GC doesn't mean you can pretend you have infinite memory). You can learn just as much about general resource management techniques in C# as in C++; I wouldn't consider that a compelling reason to bother to learn. Both are abstractions over reality anyhow. \$\endgroup\$
    – user1430
    Jan 29, 2012 at 21:59
  • 5
    \$\begingroup\$ While It is subjective, there are still lots of facts that deserve a post. Because this is closed, my response here pastebin.com/RcVFRVm5 \$\endgroup\$
    – xoofx
    Jan 30, 2012 at 2:04
  • 2
    \$\begingroup\$ @Tetrad I vote for this to be reopened, if anything because I find the answer given by xoofx to be quite interesting and deserving of being preserved. \$\endgroup\$ Jan 30, 2012 at 11:27
  • 1
    \$\begingroup\$ @Noctrine I am aware, but it is a shame that xoofx's answer will remain as a pastebin on a comment then because he wasn't fast enough to post it. \$\endgroup\$ Jan 30, 2012 at 18:52

2 Answers 2

2
\$\begingroup\$

If you're not a huge C++ fan, then the question I have is, are you already competent at C#? Any way you slice it, DirectX and its related APIs are fairly complex and you will get stuck in some places if this is your first time using a 3D graphics API. Because they are merely wrappers, they involve low-level stuff that you have to deal with on your own. If you decide you want something a bit higher-level than SlimDX or SharpDX, XNA may be another option for you, but at the trade-off that it's limited to Direct3D 9-level graphics.

The best thing, in my opinion, about using a managed D3D wrapper is that you don't have to really worry about memory leaks! The only major performance profiling you'll have to do is GPU efficiency (obviously) and garbage collection rate.

\$\endgroup\$
2
  • \$\begingroup\$ I guess the answer to the question on competency would depend on what you mean by competent. I certainly wouldn't call myself an expert, but I would probably guess that I am competent. When you say "low-level stuff that you have to deal with on your own," do you mean DirectX related things (buffers, models, shaders, etc) or more generally C++ related things (memory management, pointers, etc)? \$\endgroup\$
    – Patrick
    Jan 29, 2012 at 23:07
  • \$\begingroup\$ When I mentioned low-level stuff, I mean the stuff that is usually pertinent to most graphics APIs, so basically handling buffers, shaders, API render states, etc. \$\endgroup\$
    – ChrisC
    Jan 30, 2012 at 19:09
4
\$\begingroup\$

As APIs, SlimDX and SharpDX are almost exactly as difficult to use as the native D3D API or any other APIs they encapsulate. With a few minor exceptions, any ease-of-use benefit you get from either API comes primarily from the fact that you're using a higher level language (C#). This is because, as Martins points out in the comments on your question, they're both lightweight wrappers.

\$\endgroup\$
1
  • \$\begingroup\$ This is about what I was seeing. So, do you think it would be easier to learn DirectX (knowing I don't know much C++) or SharpDX (knowing there seem to be very few tutorials for it)? \$\endgroup\$
    – Patrick
    Jan 29, 2012 at 22:22

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