Getting rid of the framelistener

Srekel

06-11-2005 01:43:40

I've started working on a game framework (which I'll probably talk more about if it becomes something of it) written in Python, of course, and I need to not use the framelistener way of doing things.

The idea is that the application will create an instance of OGREGraphicsWrapper, which creates the ogre root, the scenemanager and all that stuff.

Then the application runs OGREGraphicsWrapper.update() each frame, and the update function basically just does root.renderOneFrame() or something, and then when the application wants to end, it calls OGREGraphicsWrapper.die().

The question is: what needs to be in die()?
This is what it looks like now...

def die(self):
"""
Called when the game is over.
This should be overridden, but System.die(self) should be the first thing that is called.
"""
System.die(self)

"Clear variables, this should not actually be needed."
del self.camera
del self.sceneManager
del self.root
del self.renderWindow




...but when I run the application in fullscreen, I get a python error (one of those basic popus) when it quits.

Srekel

06-11-2005 13:32:12

I've worked a bit more on it and tried a few things, but they all result in a crash (especially during fullscreen)..... wait. I just got it working I think. :)

It doesn't seem to crash any more, w00t! :)

Here's the code. I'm not sure everything is needed, but the last thing I added (that removed the crash) was self.renderWindow.destroy().



def die(self):
"""
Called when the game is over.
This should be overridden, but System.die(self) should be the first thing that is called.
"""
System.die(self)

print "OGRE: Clearing scene"
self.sceneManager.clearScene()

print "OGRE: Removing resources"
for resGroup in ogre.ResourceGroupManager.getSingleton().getResourceGroups():
#print "OGRE: Unloading resources", resGroup
ogre.ResourceGroupManager.getSingleton().unloadResourceGroup(resGroup)
#print "OGRE: Clearing resources", resGroup
ogre.ResourceGroupManager.getSingleton().clearResourceGroup(resGroup)
#print "OGRE: Removing resources", resGroup
ogre.ResourceGroupManager.getSingleton().destroyResourceGroup(resGroup)

print "OGRE: Shutting down all resources"
ogre.ResourceGroupManager.getSingleton().shutdownAll()

print "OGRE: Deleting the scene manager"
del self.sceneManager

print "OGRE: Deleting the render window"
self.renderWindow.destroy()
del self.renderWindow

print "OGRE: Shutting down and deleting root"
self.root.shutdown()
del self.root



I'm guessing root.destroy() might handle some of the stuff I'm doing, but since it works I'll probably leave it that way. Maybe I should put this in the wiki?

Clay

06-11-2005 17:30:04

Sure that would be great.

griminventions

07-11-2005 16:09:58

Yes, please add it to the wiki. I do not want to do the framelistener method of control, either. Definitely will be useful info. Thanks for talking about this here so we can all benefit. :)

Srekel

07-11-2005 19:34:53

I'm considering waiting a while with doing that, because I'm in the process of writing a game framework from scratch - well not 100%, I'm borrowing some parts from AVW - so I might try and do more of an article series later.

But if you need it right away I can place my entire OGREGraphicsWrapper.py there (or just paste it here).

griminventions

08-11-2005 04:09:39

I don't need it right away, but I'd definitely be interested in reading about it or seeing source when the time comes (project after next). Thanks for offering.