Gleed2Dを XNA から MonoGame に 変換しています。
Gleed2D は、インスタンス化するWindows フォーム アプリケーションですXnaGame
。window
によって作成されたはGame
非表示になり、はメイン フォームDeviceWindowHandle
の に設定されます。Canvas
私はそれがちょっとしたことを知っています。コードはそれ自体を物語っています。ここでは完全です。
関連するビットはコンストラクターにあります。
_drawSurface = mainForm.GetHandleToCanvas();
_graphics = new GraphicsDeviceManager( this )
{
PreferredBackBufferWidth = 800,
PreferredBackBufferHeight = 600
} ;
_graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings;
_winform = (Form)Form.FromHandle(Window.Handle);
_winform.VisibleChanged += game1VisibleChanged;
_winform.Size = new Size(10, 10);
Mouse.WindowHandle = _drawSurface;
Size pictureBoxSize = _mainForm.CanvasSize ;
ResizeBackBuffer( pictureBoxSize.Width, pictureBoxSize.Height ) ;
... some other stuff....
void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
e.GraphicsDeviceInformation.PresentationParameters.DeviceWindowHandle = _drawSurface;
}
私の質問は次のとおりです。XNA では、Window.Handle
を にキャストできますForm
。MonoGame では、 として実装されますOpenTK.GameWindow
。 非表示にしたりサイズを変更したりできるように、実際のウィンドウにアクセスするにはどうすればよいですか? . 別の質問としては、MonoGame を作成しGame
、レンダリング サーフェスが別のコントロールのものであることを伝えるにはどうすればよいですか?