Ogre Docking in WinForm

pizzazhang

06-05-2011 10:59:02

Hi,
I want to implement my Mesh Editor using MOgre and WinForm. I read the Wiki Tutorial about embedding Ogre into WinForm and yes it does well only if a single WinForm. But when I use WeifenLuo.WinFormsUI.Docking to add the OgreRenderForm into the Dock Panel, I found no render thing, the OgreRenderForm is empty! To be more clear, I'll paste my code:

public OgreRenderForm()
{
InitializeComponent();
this.Paint += new System.Windows.Forms.PaintEventHandler(this.OgreRenderForm_Paint);
this.Disposed += new EventHandler(OgreRenderForm_Disposed);
this.Size = new Size(800, 600);
Resize += new EventHandler(this.OgreRenderForm_Resize);
mogreWin = new OgreWindow(this.Handle);
mogreWin.InitMogre();
}

OgreRenderForm inherits form DockContent.

and OgreForm:
public OgreForm()
{
InitializeComponent();
this.Load += new EventHandler(this.OgreForm_Load);
}

private void OgreForm_Load(object sender, EventArgs e)
{
LogForm logForm = new LogForm();
logForm.Show(this.dockPanel1);
logForm.DockTo(this.dockPanel1, DockStyle.Left);
PropertyForm propertyForm = new PropertyForm();
propertyForm.Show(this.dockPanel1);
propertyForm.DockTo(this.dockPanel1, DockStyle.Left);
OgreRenderForm renderCanvas = new OgreRenderForm();
renderCanvas.Show(this.dockPanel1);
renderCanvas.DockTo(this.dockPanel1, DockStyle.Fill);
}

and the img:[attachment=0]mogre001.PNG[/attachment]
Anyone could help me? Thanks in advance!

pizzazhang

06-05-2011 11:39:45

Add: I can draw things in the RenderForm:
private void OgreRenderForm_Paint(object sender, PaintEventArgs e)
{
mogreWin.Paint();
Graphics g = e.Graphics;
g.FillEllipse(Brushes.DarkBlue, this.ClientRectangle);
}

[attachment=1]mogre002.PNG[/attachment]

I also can render Ogre scene if use a single Form:
Change Application.Run(new OgreForm());
To Application.Run(new OgreRenderForm());
[attachment=0]mogre003.PNG[/attachment]

The problem occured when I put RenderForm into the DockPanel!

pizzazhang

06-05-2011 14:31:00

well, I solved this problem.
I searched this topic http://www.ogre3d.org/addonforums/viewtopic.php?t=12030
and change my code:
renderCanvas = new OgreRenderForm();
renderCanvas.Show(this.dockPanel1);
renderCanvas.DockTo(this.dockPanel1, DockStyle.Fill);
OgreWindow ogreWin = new OgreWindow(this.renderCanvas.Handle);
ogreWin.InitMogre();
renderCanvas.initOgre(ogreWin);

I let Ogre create window all the form has its parent and use this form's handle to setup ogre render window.
It works...
[attachment=0]mogre004.PNG[/attachment]

Beauty

11-05-2011 23:21:33

Good to know how to solve the problem.
Thanks for your report. :D

Cosmas47

27-01-2016 03:44:16

Leaving this here for future users running into this issue. The creators of the DigitalRune engine have a version of the popular WeifenLuo docking library. This particular version seems to work immediately with Ogre3D and doesn't need any additional hacks to get working once the user has 'docked or undocked' the render window. Check it out over at: http://www.digitalrune.com/Docking-Windows