Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 4, 2015, 10:32:52 PM (9 years ago)
Author:
landauf
Message:

unload graphics when the game exits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/Game.cc

    r10518 r10524  
    518518
    519519            core_->loadGraphics();
    520             Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
     520            Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true);
    521521
    522522            // Construct all the GameStates that require graphics
     
    539539    }
    540540
    541     void Game::unloadGraphics()
     541    void Game::unloadGraphics(bool loadGraphicsManagerWithoutRenderer)
    542542    {
    543543        if (GameMode::showsGraphics())
     
    555555            }
    556556
    557             core_->unloadGraphics();
     557            core_->unloadGraphics(loadGraphicsManagerWithoutRenderer);
    558558        }
    559559    }
     
    576576
    577577        // If state requires graphics, load it
    578         Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
     578        Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true);
    579579        if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics())
    580580            this->loadGraphics();
     
    612612        }
    613613        // Check if graphics is still required
    614         if (!bAbort_)
    615         {
    616             bool graphicsRequired = false;
    617             for (unsigned i = 0; i < loadedStates_.size(); ++i)
    618                 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
    619             if (!graphicsRequired)
    620                 this->unloadGraphics();
    621         }
     614        bool graphicsRequired = false;
     615        for (unsigned i = 0; i < loadedStates_.size(); ++i)
     616            graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
     617        if (!graphicsRequired)
     618            this->unloadGraphics(!this->bAbort_); // if abort is false, that means the game is still running while unloading graphics. in this case we load a graphics manager without renderer (to keep all necessary ogre instances alive)
    622619        this->bChangingState_ = false;
    623620    }
Note: See TracChangeset for help on using the changeset viewer.