@Rob Loach:
Thx for your answer, I just read it today. I downloaded SWIG and after some reading and several tries I finally managed to get a C# wrapper that compiles and is usable.
One problem I have with that though is the following:
the SWIG wrapper created a SWIGTYPE_p_HWND. The Init() function of my engine expects a HWND to be passed in there, which is the HWND I use to initialize D3D and so on. The SWIG wrapper Init() function expects a SWIGTYPE_p_HWND to be passed. So I just did the following:
// this is in my C# project and uses the SWIG wrapperEngine GFX = new Engine();// 'this' is a Form, from which I get the handle // and build a SWIGTYPE_p_HWND with it. // The second parameter for the Init() function is fullscreen yes/noGFX.Init(new SWIGTYPE_p_HWND(this.Handle, true), false);
As far as I understand that whole stuff, this should work, yet my engine throws an error which indicates that the HWND it received isn´t usable, hence device creation fails.
@my last post about the functions resulting in unresolved tokens and unresolved externals:
I noticed that the 2 functions causing those errors are the only ones using LPCTSTR as parameters. So perhaps this is the reason for my problems with these functions, though I don´t know what to do about it... changing the unmanaged engine to something differen just to make the wrapper work seems overkill for me.
Taking those 2 functions out, everything compiles fine (okay, it renders the engine practically useless). Now I would be ready to use that thing. However I always get the same error, namely that "ManagedEngine.dll" could not be found. This error appears no matter where I copy that dll (at least I tried every location I deemed worthy to try out).
To make things easier, again some source:
ManagedEngine.h:
#include "Engine.h"using namespace System;namespace ManagedEngine { public ref class EngineWrapper { public: static void Create(); static void Delete(); static int Init(System::IntPtr window, bool bFullscreen); static int Update(System::Int64 time); static void ShutDown(); private: static PUKE::Engine* m_pEngine; };}
Together with the according ManagedEngine.cpp this compiles fine into ManagedEngine.dll .
After that I created a small C# project in VS2005 called EngineWrapper.
Here is the complete source contained in there:
using System.Runtime.InteropServices;namespace Chess{ public class EngineWrapper { [DllImport("ManagedEngine.dll")] public static extern void Create(); [DllImport("ManagedEngine.dll")] public static extern void Delete(); [DllImport("ManagedEngine.dll")] public static extern int Init(System.IntPtr window, bool bFullScreen); [DllImport("ManagedEngine.dll")] public static extern int Update(System.Int64 time); [DllImport("ManagedEngine.dll")] public static extern void ShutDown(); }}
This is compiled into EngineWrapper.dll.
EngineWrapper.dll is then referenced in my Chess project and the functions are used.
But whenever I call one of these functions I get the error telling me ManagedEngine.dll could not be found. I tried referencing that DLL from the EngineWrapper project, yet no success.
I also tried putting the EngineWrapper.cs into the Chess project directly, same error, of course...
I guess that could be easily fixed if I would know where I should put that ManagedEngine.dll.
Thx for helping!