panel rendering


05-01-2009 17:03:47


Could not get my head around this. So I created a render target to a panel like so:

NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = this.panel1.Handle.ToString();
mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

and then I implement the paint event handler and call root's RenderOneFrame method.

Something tells me I need to use Root::StartRendering or at least have my application render as fast as it can - and not only when a onPaint event is triggered by .NET.

The problem I can't call Root::StartRendering because it locks up the whole application. I'm creating an editor where there are panels, property grid, dock panels etc., and the render panel is just one among the other gui controls.



05-01-2009 21:04:41

Have you checked the Mogre Basic Tutorial 6?

This is, what you're looking for. The loop makes sure, all Form events are being processed and also keeps Mogre up to date. You either break the loop by disposing mRoot (e.g. in the event the Form gets closed/disposed) or by returning false in the mRoot.FrameStarted or mRoot.FrameEnded event.
while (mRoot != null && mRoot.RenderOneFrame()) {

Don't add the rendering to the Form's paint event. This isn't a very "clean" way.
Btw, you don't have to use StartRendering(), it's just calling RenderOneFrame() in a loop. The method RenderOneFrame() ist just fine.


06-01-2009 03:56:31

Yes, actually that's the code I'm using and I refrain from calling the method Go(...), because once I call that, my applications stops right there - that is, my other gui controls / other parts of my C# application does not get initialize anymore.

I have program.cs which only have these code:

Application.Run(new MainForm());

Mainform job is to initialize all the other forms, like so:


DockPanel dockPanel = new DockPanel();
dockPanel.Dock = DockStyle.Fill;
dockPanel.BackColor = Color.Beige;

PropertiesDock[code][/code]Content content1 = new PropertiesDockContent(this);
content1.ShowHint = DockState.DockRight;
content1.BackColor = Color.SteelBlue;

OgreForm ogreForm = new OgreForm();
ogreForm.ShowHint = DockState.Document;
ogreForm.BackColor = Color.Black;

You see I have commented out the method go from the OgreForm, if I don't, my app would lock up. Why? because it gets stock in the while loop of the Go method:

while (mRoot != null && mRoot.RenderOneFrame())

So my application initialization process would stop right there, but as far as my application initalization process, that's the last initialization code though I might need to relinquish control to the .NET framework still so my forms would show up or else it won't.

this is where I could not get my head around.


06-01-2009 12:52:59

Okay thanks all.

Raygee your post helped as well for reinforcing to me that the code snippet you showed should work.

I made sure that the loop is called last when everything is already showing (eg, my forms are showing and so on).


06-01-2009 13:26:31

Glad to be of help. :-)

This way you're replacing the Application.Run() -loop (which keeps a form alive) with your own loop. Both loops would only work if they were in different threads