Luth
25-04-2010 10:27:52
Hi.
I'm playing around a little with Mogre and have some problems with it. (Apart from taking a long time to get it running in VS2010 )
Everytime i close my application, i get an ObjectDisposedException. The application is started in the following way,
using a Singleton instance containing a Windows Form.
I am creating my renderwindow like this:
So i do not let Mogre create the window itself, but initialize it on an existing form.
Next i registered a formclosing-event and a framehandler to do a clean up, after i finished rendering.
The Problem is: It seems that Mogre is destroying the renderwindow by itself, when closing down. It doesn't care about, if it has created the
renderwindow or just been given a window handle. So everytime i close my form, i get an ObjectDisposedException for the form used in
" Application.Run(Core.getSingleton().Config.Graphics.Window)". Is that the intented behaviour? And if so, does anyone have an idea how
i can work around it, except simply suppressing the exception?
The second thing i want to ask is, whether there is a general rule of thumb, what resources i have to clean up myself and what is done by Mogre.
Do i have to dispose the singleton managers (like ResourceGroupManager or MaterialManager) and / or materials myself?
Do i have to dispose or set null all the MaterialPointers, Meshpointers, SceneNodes, Entities or other resources?
Probably yes, since all those things are created by an unmanaged dll, but i would feel better if someone could clear that up for me.
Thanks for answering.
I'm playing around a little with Mogre and have some problems with it. (Apart from taking a long time to get it running in VS2010 )
Everytime i close my application, i get an ObjectDisposedException. The application is started in the following way,
using a Singleton instance containing a Windows Form.
Application.Run(Core.getSingleton().Config.Graphics.Window);
I am creating my renderwindow like this:
Window = new Form();
...
MRoot.Initialise(false, "MainWindow");
...
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = Window.Handle.ToString();
MRenderWindow = MRoot.CreateRenderWindow("MainWindow",(uint)Screenwidth,(uint)Screenheight,Fullscreen,misc);
So i do not let Mogre create the window itself, but initialize it on an existing form.
Next i registered a formclosing-event and a framehandler to do a clean up, after i finished rendering.
Config.Graphics.MRoot.FrameStarted += new FrameListener.FrameStartedHandler(Handle_FrameStarted);
Config.Graphics.Window.FormClosing += new FormClosingEventHandler(Window_FormClosing);
Config.Graphics.MRoot.StartRendering();
Shutdown();
...
void Window_FormClosing(object sender, FormClosingEventArgs e)
{
StopRendering = true;
}
...
bool Handle_FrameStarted(FrameEvent evt)
{
return (!StopRendering);
}
The Problem is: It seems that Mogre is destroying the renderwindow by itself, when closing down. It doesn't care about, if it has created the
renderwindow or just been given a window handle. So everytime i close my form, i get an ObjectDisposedException for the form used in
" Application.Run(Core.getSingleton().Config.Graphics.Window)". Is that the intented behaviour? And if so, does anyone have an idea how
i can work around it, except simply suppressing the exception?
The second thing i want to ask is, whether there is a general rule of thumb, what resources i have to clean up myself and what is done by Mogre.
Do i have to dispose the singleton managers (like ResourceGroupManager or MaterialManager) and / or materials myself?
Do i have to dispose or set null all the MaterialPointers, Meshpointers, SceneNodes, Entities or other resources?
Probably yes, since all those things are created by an unmanaged dll, but i would feel better if someone could clear that up for me.
Thanks for answering.