mzanin
29-07-2010 05:08:22
Hello,
I have a question in regards to the order in which to dispose objects and if it is meant to be hierarchical?
Also I wish to know what the standard way of disposing Materials and Textures is?
For example at the end of my application I do this:
Is this really necessary or can I simply m_Root.Dispose(), and that in turn will dispose all it's children etc.?
In regards to the materials/textures, in places I do this (for example)...
Will disposing/destroying the ManualObject not dispose all it's "children" (including the material and in turn the texture) anyway?
Or disposing the Material not dispose the texture as well?
Also is there any difference in calling
Another thing I do is dispose the MaterialPtr straight after I use it... eg.
Is this the correct way to do this?
Lastly is it necessary at the end of the program to call dispose on all the managers? For example
Hopefully someone can clarify this for me as it's been bugging me for a while.
I have a question in regards to the order in which to dispose objects and if it is meant to be hierarchical?
Also I wish to know what the standard way of disposing Materials and Textures is?
For example at the end of my application I do this:
MaterialManager.Singleton.RemoveAll();
if (m_SceneManager != null)
{
m_SceneManager.ClearScene();
m_Root.DestroySceneManager(m_SceneManager);
}
if (m_RenderSystem != null && m_RenderWindow != null)
{
m_RenderSystem.EventOccurred -= RenderSystemListener;
m_RenderSystem.DestroyRenderWindow(m_RenderWindow.Name);
}
if (m_Root != null)
{
ResourceGroupManager.Singleton.Dispose();
m_Root.Shutdown();
m_Root.Dispose();
m_Root = null;
}
Is this really necessary or can I simply m_Root.Dispose(), and that in turn will dispose all it's children etc.?
In regards to the materials/textures, in places I do this (for example)...
m_Texture.DisposeIfNotNull();
m_Texture = null;
MaterialManager.Singleton.Remove(m_Identifier.Name);
m_SceneManager.DestroyManualObject(m_ManualObject);
m_SceneManager.DestroySceneNode(m_Node);
Will disposing/destroying the ManualObject not dispose all it's "children" (including the material and in turn the texture) anyway?
Or disposing the Material not dispose the texture as well?
Also is there any difference in calling
m_Texture.Dispose()
compared to calling TextureManager.Singleton.Remove(m_Texture.Name);
Another thing I do is dispose the MaterialPtr straight after I use it... eg.
MaterialPtr materialPtr = MaterialManager.Singleton.Create(m_MaterialName, "General");
materialPtr.RemoveAllTechniques();
var technique = materialPtr.CreateTechnique();
materialPtr.Dispose();
Is this the correct way to do this?
Lastly is it necessary at the end of the program to call dispose on all the managers? For example
TextureManager.Singleton.Dispose();
MaterialManager.Singleton.Dispose();
...
Hopefully someone can clarify this for me as it's been bugging me for a while.