Sign in to follow this  
sylefeb

[.net] D3D Device from C# to unmanaged C++

Recommended Posts

sylefeb    122
Hi All, Here is my problem: On one hand C# is great for fast dev and UIs, but on the other hand I have a huge - rather non trivial - code base in (unmanaged) C++ / DirectX. So, quite obviously, I would like to create a D3D device from C# and invoke unmanaged C++ methods, passing the device pointer to them (IDirect3DDevice9*), so that rendering can happen from unmanaged C++. Does anyone have experience on this? I have searched the forum (hope I did not miss the answer), but most posts are about interop between managed/unmanaged C++ - What I would like is C# to unmanaged C++. I know window handles (HWND) can be passed btw C# and a C++ DLL, but initializing the device on C# side seems much more elegant (and, let's face it, so much easier!). Thanks! Sylvain.

Share this post


Link to post
Share on other sites
gharen2    520
You want Device.UnmanagedComPointer.

It returns a pointer to the unmanaged device. Pass it to c++, cast it to an IDirect3DDevice9*, and you should be set.

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