[.net] Wraping lots of unmanaged code in a managed layer

Started by
5 comments, last by Mulligan 18 years, 10 months ago
I have an engine written entirely in c++ with pure virtual classes exported from dlls to represent each of the major engine components i.e (video, audio, input, etc). The game itself if written in c++ as well, so thats no problem. The editor on the other hand, I will be writing in managed C#. I've had some experience in calling unmanaged code from managed code, but not on a large scale. Are there any general stratagies for attacking this problem?
Advertisement
Read this on MSDN, should be enough info.
Also read the articles on Pinvoke.net

Cheers
Thanks
The best way imo is to have an engine with a single point of contact and write a managed C++ wrapper. From there you can just use the wrapper with C#.

I have done this in the past with my engine and it works great for the editor, and I know of at least one major engine that does this as well.
After reading those articles posted above, thats what I'm going to do. I have several clearly defined interfaces to each engine component, but it seems the hard part is going to be duplicating the structures that my engine interfaces accept as parameters.

Actually, ive got one more question.

I fully intend to keep the actual engine code to be unmanaged. Also, after reading all of those documents, it seems that if I structured my engine using COM interfaces, the .NET portability issues would be largely eliminated, and future enhancements to the engine would be very easy to use in .NET.

I've never created COM components before, but have read lots of material on the subject, so im fairly familiar with the process.

Do you think its worth it to convert my engine to COM?

This topic is closed to new replies.

Advertisement