Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to create a wrapper class that exposes certain functionality of your game.</p> <p>For example. This function is in my c++ game engine editor wrapper.</p> <pre><code>extern "C" _declspec(dllexport) void SetPlayerPos(int id, const float x, const float y, const float z); </code></pre> <p>Then in your c# wpf application you can create a static class allowing you to use those functions</p> <pre><code>[DllImport(editorDllName, CallingConvention = CallingConvention.Cdecl)] public static extern void SetPlayerPos(int id, float x, float y, float z); </code></pre> <p>You will have to have functions for your basic functionality of the game engine through the dll. things like</p> <p>EditorMain RenderFrame / Update DXShutdown</p> <p>So then you can call editormain in your wpf app constructor</p> <pre><code>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); </code></pre> <p>You will need to create a message filter class and initialize it in the constructor as well</p> <pre><code>m_messageFilter = new MessageHandler(this.Handle, this.DisplayPanel.Handle, this); </code></pre> <p>here's how your message filter class could look</p> <pre><code>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 { // Render the scene NativeMethods.RenderFrame(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } </code></pre> <p>for doing win forms and wpf interop look here <a href="http://msdn.microsoft.com/en-us/library/ms742474.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms742474.aspx</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload