Problem Destroying and re-creating mogre engine

Sickes

28-06-2008 21:14:14

Hi!

I have a system that creates and initialize the mogre engine. After it using I need destroy all and create the mogre engine again (whith the same code).
I have problems trying this last part.

First I don't know exactly what I must destroy to unload completely mogre.
Now i do the next:

mRoot.QueueEndRendering();

mRoot.Shutdown();

//destruimos todo

//destruimos la scena
sManager.DestroyAllCameras();
sManager.DestroyAllEntities();
sManager.DestroyAllMovableObjects();
sManager.ClearScene();
mRoot.DestroySceneManager(sManager);
sManager.Dispose();
sManager = null;

//destruimos los handlers a eventos(NADA)

//Destruimos los listeners

//Destruimos los resource groups
ResourceGroupManager.Singleton.ClearResourceGroup("General");

//destruimos la render window
mRoot.DetachRenderTarget(window);
window.Destroy();
window = null;




When I initialize the mogre again it throws me a exception when create the Scene:
OGRE EXCEPTION(5:ItemIdentityException): Unable to derive resource group for planomesa automatically since the resource was not found. in ResourceGroupManager::findGroupContainingResource at ...

in the second line of this code:

MeshManager.Singleton.CreatePlane("planomesa", "General", plano, 1024, 768);

Entity ePlanoCara = mgr.CreateEntity("mesa", "planomesa");


It seems that mogre can't find the Group of Mesh "planomesa" and the findGroupContainingResource method throws the exception. But the first time I initialize mogre and I create the scene all works fine.


Does anybody can help me?

Thanks

baconfish

30-06-2008 15:30:37

Why aren't you doing mRoot.Shutdown() after destroying everything else?

Sickes

30-06-2008 15:57:12

I tried it but in the second initialize crash with the same error.


OGRE EXCEPTION(5:ItemIdentityException): Unable to derive resource group for planomesa automatically since the resource was not found. in ResourceGroupManager::findGroupContainingResource at ...

raygeee

30-06-2008 22:22:58

I'm using this, additionally to your code:
...
_RenderWindow.Destroy();
_RenderWindow.Dispose();
_RenderWindow = null;
_Root.Dispose();
_Root = null;


I just found out... Maybe this helps?
ResourceGroupManager.Singleton.ShutdownAll();
and/or
ResourceGroupManager.Singleton.Dispose();


btw, what does Root.Shutdown() actually do?

edit: this topic refers to Root.Dispose() as well.