Jump to content



Is it a good idea to use both C# and C++ with DirectX

  • You cannot reply to this topic
4 replies to this topic

#1 EmperorXYZ   Members   -  Reputation: 100

Like
0Likes
Like

Posted 03 February 2012 - 02:59 PM

Reason for asking: I've recently learned C# and really like it. It's just that I've been able to find ressources explaining well the BLC. I'm sure C++ also have similar libraries, but from how difficult it was for me to start learning Boost, I'd rather use C#.

So, I was wondering if that would be a good idea or there are hidden reasons, such as performance issues or lack of compatibility. I was planning on using C++ DLLs to make DirectX calls and use C# for game logic and pretty much everything else.

Ad:

#2 Ripiz   Members   -  Reputation: 120

Like
-1Likes
Like

Posted 03 February 2012 - 03:06 PM

You don't need to learn or use Boost for C++. Personally I don't think it provides anything useful.

C# isn't much slower than C++ as far as I know. There's no need to create C++ library either, you could use something like XNA (http://create.msdn.com/en-US/), and I'm sure C# has a way to use DirectX (I'm not using it, so I do not know how to do that).

#3 frob   Moderators   -  Reputation: 2055

Like
-1Likes
Like

Posted 03 February 2012 - 03:27 PM

Yes, you can mix C# and C++. They are compiled into object files and you can link them together however you please.

There is no reason to just use C++ as a wrapper. Not only do you have XNA, but there are other projects like SlimDX that already handle it for you.
Recently made a moderator, but still a regular programmer.

#4 MJP   Moderators   -  Reputation: 2119

Like
0Likes
Like

Posted 03 February 2012 - 03:36 PM

Interop between C# and C++ can be a major pain in the ass, and I don't suggest putting yourself through it if you don't have to. Libraries like SlimDX and SharpDX have already done all of the hard work of wrapping DX, so if that's your goal then you should consider using those instead.

#5 EmperorXYZ   Members   -  Reputation: 100

Like
0Likes
Like

Posted 03 February 2012 - 04:19 PM

I see thanks. Well, I'm still at the learning phase and I'd like to write a project or two where I'd have to go fairly low level with DirectX. After that, I'm all for less painful code writting. I'll check out SlimDX, SharpDX or XNA once I have a fairly solid grasp on how DX works. I'm also wondering about DXUT as even if I'm writting a complete C++ project, I still want shortcuts.






We are working on generating results for this topic
PARTNERS