Swap game state error

Toby

19-12-2006 09:34:23

Hello, I'm trying to create a game state machine using for menu intro BetaGUI(great but you ll laugh of me) and using a nxOgre_World for playsate.
I can launch application and go on menu, launch playstate and come back to menu, but when I re-launch playstate I obtain this error:

10:08:30: An exception has been thrown!

-----------------------------------
Details:
-----------------------------------
Error #: 6
Function: ResourceManager::add
Description: Resource with the name NxOgre.ErrorCube already exists..
File: \OgreDev\Dagon\OgreMain\src\OgreResourceManager.cpp
Line: 89
Stack unwinding: <<beginning of stack>>


When I quit my playstate I do this:

void PlayState::exit()
{

delete mWorld;

if(mVehicle)
delete mVehicle;

mSceneMgr->clearScene();
mSceneMgr->destroyAllCameras();
mRoot->getAutoCreatedWindow()->removeAllViewports();
mSceneMgr->destroyAllBillboardSets();
mSceneMgr->destroyAllParticleSystems();
mSceneMgr->destroyAllMovableObjects();
mSceneMgr->destroyAllEntities();
mSceneMgr->destroyAllLights();
mSceneMgr->destroyAllManualObjects();
mSceneMgr->destroyAllStaticGeometry();
mSceneMgr->destroyAllAnimations();
mSceneMgr->destroyAllAnimationStates();

std::cout << "PlayState exit\n";
}


For each state I create a new SceneManager and for playstate I create a new world.

What is wrong? thx

betajaen

19-12-2006 10:08:03

You shouldn't delete world like that, it's a singleton.

world::reset is what you need.

Toby

19-12-2006 13:21:26

Yes, you are allright. But I want to delete completly world and return to my first game state (menu without world). Then I will use world::release function that destroy all scene, remove framelistener and destroy all scene attached.
But I obtain same error.
Must I destroy resources or something like this?

thanks for your help. :roll:

Toby

19-12-2006 14:08:19

Hum, I am so stupid sometimes. I use like you say worldreset and it s work fine. I use static game state like in exemple in Ogre wiki and world will not be deleted as I try.

I consider this solved, but memory leaks will appears or not?

thx

betajaen

19-12-2006 18:22:11

No, there shouldn't be any leaks.