Unmanaged DX in C#. Possible?

Started by
3 comments, last by ET3D 14 years, 1 month ago
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
Advertisement
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#.
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?

throw table_exception("(? ???)? ? ???");

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?
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.)

This topic is closed to new replies.

Advertisement