- fixed memory leaks in map editor, g3dviewer and the game

This commit is contained in:
Mark Vejvoda
2012-07-21 20:21:27 +00:00
parent 8d168bdb4c
commit e1054d6e07
4 changed files with 34 additions and 3 deletions

View File

@@ -113,6 +113,11 @@ Renderer::~Renderer() {
//resources
delete particleManager;
delete modelManager;
if(GraphicsInterface::getInstance().getFactory() != NULL) {
delete GraphicsInterface::getInstance().getFactory();
GraphicsInterface::getInstance().setFactory(NULL);
}
}
Renderer * Renderer::getInstance() {
@@ -174,8 +179,11 @@ Model * Renderer::getNewModel() {
void Renderer::init() {
assertGl();
GraphicsFactory *gf= new GraphicsFactoryGl();
GraphicsInterface::getInstance().setFactory(gf);
GraphicsFactory *gf= GraphicsInterface::getInstance().getFactory();
if(gf == NULL) {
gf= new GraphicsFactoryGl();
GraphicsInterface::getInstance().setFactory(gf);
}
modelRenderer= gf->newModelRenderer();
textureManager= gf->newTextureManager();