Skip to main content
GameDev.net gamedev.net
🔒 Locked

Managed C++ wrapper or DllImport?

Started by joanusdmentia Jun 5, 2004 at 7:27 PM 1 replies 2.3k views
Original Post
joanusdmentia
joanusdmentia
I''m looking at using the recently released ODE 0.5 in a game being written in C#, however the provided .NET wrapper in the contrib/ dir don''t look like they''ve been updated to 0.5 so I''m going to write my own. Does anyone know whether there is any performance difference between writing managed C++ wrapper classes and compiling all of ODE into a managed assembly or just using the DllImport attribute in C# to call the functions in an unmanaged ODE dll? I''m currently leaning towards using DllImport since it would make things a bit more portable (as far as I know mono can''t handle mixed assemblies), but if the speed difference is enough then I''ll go with the C++ wrapper classes.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The nly verdict is vengeance; a vendett o
Arild Fines
Arild Fines
I''d think a Managed C++ solution would be slightly faster than P/Invoke. P/Invoke involves quite a bit of marshalling magic in some cases, and there is a reason why the general guideline is that P/Invoke calls should be few and chunky.

A mixed MC++ assembly shouldn''t require any marshalling.

(All of the above is just educated guesswork based on my knowledge of the technologies - I haven''t actually tested it.)

One thing, which may or may not be relevant in your case, is that mixed-mode MC++ assemblies won''t run under Mono or any other alternative .NET implementation, nor will they compile there unless someone develops an MC++ compiler for them. This is because mixed-mode assembles contain, by definition, unmanaged code, which is bound to the underlying platform.

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
joanusdmentia
joanusdmentia
quote:
Original post by Arild Fines
I''d think a Managed C++ solution would be slightly faster than P/Invoke. P/Invoke involves quite a bit of marshalling magic in some cases, and there is a reason why the general guideline is that P/Invoke calls should be few and chunky.

A mixed MC++ assembly shouldn''t require any marshalling.

That makes sense. Not really sure about MC++ assemblies not requiring marshalling though, I would have thought it would still be needed for passing objects between the managed and unmanaged C++ (I haven''t really done much with MC++ before, just C# as far as managed code goes).

quote:
Original post by Arild Fines
One thing, which may or may not be relevant in your case, is that mixed-mode MC++ assemblies won''t run under Mono or any other alternative .NET implementation, nor will they compile there unless someone develops an MC++ compiler for them. This is because mixed-mode assembles contain, by definition, unmanaged code, which is bound to the underlying platform.

This is as I thought and is the reason why I was leaning towards P/Invoke. Having said that though I won''t loose any sleep if it doesn''t end up being portable, it''s just something that would be ''nice'' to have the option of.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The nly verdict is vengeance; a vendett o

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.