Sign in to follow this  
FenixRoA

Unmanaged DX in C#. Possible?

Recommended Posts

Is it possible to use unmanaged DX calls (using P/Invoke or whatever) in C#? I ask because I know some things can't be done in C# (such as installing certain global hooks). SlimDX doesn't work for me, and I know that the managed DirectX library has been unsupported for a while in favor of the XNA library. Thanks, ~FenixRoA

Share this post


Link to post
Share on other sites
It's kind of a mess, but it's possible. Here are the details. The first link describes some COM stuff and how to deal with it in C++, and the second details how to deal with COM from C#.

MSDN :: Programming DirectX with COM

MSDN :: COM Interop Part 1: C# Client


That said, if you want to do most of your stuff in C#+XNA and some of the stuff you can't normally do in C++, you can make a C++/CLI DLL that your C# can use, far more easily than using DirectX COM from C#.

Share this post


Link to post
Share on other sites
Why exactly wouldn't SlimDX work for you? Its implimented with the same P/Invoke you'd be doing yourself, but its already written and quite complete. The guys behind it have already invested significant amounts of time (man-years, I'm sure) learning all the ins and outs of com inter-op, come up with a consistent API, and done all the grunt-work. Is there a real basis for your avoiding it, or is there some mis-assumption here?

Share this post


Link to post
Share on other sites
Quote:
Original post by FenixRoA
SlimDX doesn't work for me
I think this is the problem you should be solving, rather than trying to write your own wrapper (after all, SlimDX is just a wrapper around native DirectX as well). Why doesn't it work?

Share this post


Link to post
Share on other sites
Since SlimDX is doing what you want and it's open source, you can modify it to your liking or just take what you need from it. (Especially since it's MIT licensed.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this