Changeset 10524 for code/branches/core7/src
- Timestamp:
- Jun 4, 2015, 10:32:52 PM (9 years ago)
- Location:
- code/branches/core7/src/libraries/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/Core.cc
r10520 r10524 309 309 310 310 // Any exception should trigger this, even in upgradeToGraphics (see its remarks) 311 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics );311 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics, true); 312 312 313 313 // Upgrade OGRE to receive a render window … … 357 357 } 358 358 359 void Core::unloadGraphics( )359 void Core::unloadGraphics(bool loadGraphicsManagerWithoutRenderer) 360 360 { 361 361 orxout(internal_info) << "unloading graphics in Core" << endl; … … 368 368 // Load Ogre::Root again, but without the render system 369 369 try 370 { this->graphicsManager_ = new GraphicsManager(false); } 370 { 371 if (loadGraphicsManagerWithoutRenderer) 372 this->graphicsManager_ = new GraphicsManager(false); 373 } 371 374 catch (...) 372 375 { -
code/branches/core7/src/libraries/core/Core.h
r10518 r10524 80 80 81 81 void loadGraphics(); 82 void unloadGraphics( );82 void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); 83 83 84 84 void loadModules(); -
code/branches/core7/src/libraries/core/Game.cc
r10518 r10524 518 518 519 519 core_->loadGraphics(); 520 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics );520 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true); 521 521 522 522 // Construct all the GameStates that require graphics … … 539 539 } 540 540 541 void Game::unloadGraphics( )541 void Game::unloadGraphics(bool loadGraphicsManagerWithoutRenderer) 542 542 { 543 543 if (GameMode::showsGraphics()) … … 555 555 } 556 556 557 core_->unloadGraphics( );557 core_->unloadGraphics(loadGraphicsManagerWithoutRenderer); 558 558 } 559 559 } … … 576 576 577 577 // 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); 579 579 if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics()) 580 580 this->loadGraphics(); … … 612 612 } 613 613 // 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) 622 619 this->bChangingState_ = false; 623 620 } -
code/branches/core7/src/libraries/core/Game.h
r10479 r10524 148 148 149 149 void loadGraphics(); 150 void unloadGraphics( );150 void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); 151 151 152 152 void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode);
Note: See TracChangeset
for help on using the changeset viewer.