You need to create a wrapper class that provides certain functions to your game.
For instance. This function is in my shell of the editor of the engine for C ++ files.
extern "C" _declspec(dllexport) void SetPlayerPos(int id, const float x, const float y, const float z);
Then in your C # wpf application you can create a static class that allows you to use these functions
[DllImport(editorDllName, CallingConvention = CallingConvention.Cdecl)] public static extern void SetPlayerPos(int id, float x, float y, float z);
You will need to have functions for your basic functions of the game engine through dll. such things as
EditorMain RenderFrame / DXShutdown Update
So you can call editormain in your wpf app constructor
System.IntPtr hInstance = System.Runtime.InteropServices.Marshal.GetHINSTANCE(this.GetType().Module); IntPtr hwnd = this.DisplayPanel.Handle; NativeMethods.EditorMain(hInstance, IntPtr.Zero, hwnd, 1, this.DisplayPanel.Width, this.DisplayPanel.Height);
You will need to create a message filter class and initialize it also in the constructor
m_messageFilter = new MessageHandler(this.Handle, this.DisplayPanel.Handle, this);
here what the message filter class looked like
public class MessageHandler : IMessageFilter { const int WM_LBUTTONDOWN = 0x0201; const int WM_LBUTTONUP = 0x0202; IntPtr m_formHandle; IntPtr m_displayPanelHandle; EngineDisplayForm m_parent; public MessageHandler( IntPtr formHandle, IntPtr displayPanelHandle, EngineDisplayForm parent ) { m_formHandle = formHandle; m_displayPanelHandle = displayPanelHandle; m_parent = parent; } public bool PreFilterMessage(ref Message m) { if (m.HWnd == m_displayPanelHandle || m.HWnd == m_formHandle) { switch (m.Msg) { case WM_LBUTTONDOWN: case WM_LBUTTONUP: { NativeMethods.WndProc(m_displayPanelHandle, m.Msg, m.WParam.ToInt32(), m.LParam.ToInt32()); if (m.Msg == WM_LBUTTONUP) { m_parent.SelectActor(); } return true; } } } return false; } public void Application_Idle(object sender, EventArgs e) { try {
to create win forms and wpf interop http://msdn.microsoft.com/en-us/library/ms742474.aspx