Ste*_*unn 5 xna opentk monogame
我正在将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;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:在XNA中,Window.Handle可以转换为Form.在MonoGame中,它被实现为OpenTK.GameWindow. 如何进入实际窗口以便隐藏和/或调整大小?.另一个问题是:如何创建MonoGame Game并告诉它渲染表面是另一个控件的表面?
小智 1
在创建本机窗口之前,OpenTK 的 GameWindow 已经走了很长一段路。在此页面上,您可以看到本机实现:https://github.com/mono/opentk/blob/master/Source/OpenTK/Platform/Windows/WinGLNative.cs
我的解决方案是破解 OpenTK 的源代码或在 OpenTK 论坛中提问。
| 归档时间: |
|
| 查看次数: |
2584 次 |
| 最近记录: |