I'm having a headache of a time with the destruction side of things with the IGUIEnvironment object (rather the derived object built from the createDevice() call).
I've only been toying with the Irrlicht engine for about a week now, give or take, so what I'm wanting to do could very easily be way off. A pseudo layout of how I have things going...
class GameFrame{
**irrlicht device, pointers to gui, scene, etc.**
GameStage* stage;
void Render(){
if(!stage->isDone())
stage->Render();
else{
delete stage;
stage = new NextGameStage();
}
}
};
int main(){
GameFrame* frame = new GameFrame();
while(frame->Running()){
frame->Render();
}
}
GameStage is a base class that I'm deriving different "chunks" of the application off of. IE. LoadingStage, MainMenuStage, etc.
I've been having a lot of occasions where loading a new stage creates crash errors, however they seem to be directly related to the destruction of the previous stage. Generally, although not always, I can comment out the entire destructor for the previous stage and all goes well. However the gui elements of the previous stage, obviously, continue to render right over the top of things. I have toyed around some with this and can't come to a good solution. Also I have noticed that sometimes I can get things to work perfectly in windowed mode but if I switch to fullscreen things crash and burn. The destructor for the device object returned from createDevice() seems to work fine (I never get any errors when the program exits) so I thought of trying to drop the gui environment object and rebuild it, but I'm not sure what it is exactly although I assume it is derived from IGUIEnvironment. Also I tried to use the getRootElement()->getChildren(); method to iterator through and destroy each object by hand to no avail.
I could just drop the entire device object and build a new one, but I want to avoid all that ugly resolution changing that will occur from that.
Basically I want to destroy everything the gui manager has. A similar effect to calling clear() for the scene manager. Or if you have any other ideas that would be great too.
Any help would be appreciated.
-Zann
Problems deallocating GUI objects
I'm not sure (the documentation seems to be obscure if it is the case), but i think that deleting the root node would delete all his children in sequence automatically.
If that is true, you shouldn't try to delete the nodes one-by-one or, if you still do it, you should go through the node tree starting always by the leaves
If that is true, you shouldn't try to delete the nodes one-by-one or, if you still do it, you should go through the node tree starting always by the leaves