Jump to content
  • Advertisement
Sign in to follow this  
sylefeb

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

This topic is 3935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!