I'm trying to port some functionality from my engine from c++ to C#. I compile my engine as a dll with unmanaged c++ and only use extern "C" functions in the C# wrapper.
I have various functions that take and return Vector3df
. This is defined as
typedef Vector3d<f32> Vector3df;
and f32
is a actually a float
. The class itself has nothing more than some members called x y and z and a lot of methods.
I can rewrite the whole class in C#, that's not a problem but is there anyway in which the 2 could be matched?
Let's take for example the following functions:
extern "C" void SetColor(Vector3df color)
extern "C" Vector3df GetColor()
I would like to have something like this in C#:
[DllImport("Engine.dll", EntryPoint = "SetColor", CallingConvention = CallingConvention.Cdecl)]
static extern void SetColor(Vector3df color);
[DllImport("Engine.dll", EntryPoint = "GetColor", CallingConvention = CallingConvention.Cdecl)]
static extern Vector3df GetColor();
Is there anyway in which I could make code similar to this work?
Note that I'm not by any means a C# guru.I'm lost when it comes to marshaling. I'm mostly doing this to make a map editor for my game without having to learn Qt or wxWidgets.
Thank you!