Changeset 5658 for code/branches/resource2/src/core/Core.cc
- Timestamp:
- Aug 18, 2009, 11:14:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource2/src/core/Core.cc
r5655 r5658 303 303 void Core::loadGraphics() 304 304 { 305 if (bGraphicsLoaded_)306 return;305 // Any exception should trigger this, even in upgradeToGraphics (see its remarks) 306 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics); 307 307 308 308 // Upgrade OGRE to receive a render window … … 314 314 315 315 // Calls the InputManager which sets up the input devices. 316 scoped_ptr<InputManager> inputManager(new InputManager(windowHnd));316 inputManager_.reset(new InputManager(windowHnd)); 317 317 318 318 // load the CEGUI interface 319 319 guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow())); 320 320 321 // Dismiss scoped pointer 322 inputManager_.swap(inputManager); 321 unloader.Dismiss(); 323 322 324 323 bGraphicsLoaded_ = true; … … 327 326 void Core::unloadGraphics() 328 327 { 329 if (!bGraphicsLoaded_)330 return;331 332 328 this->guiManager_.reset();; 333 329 this->inputManager_.reset();; … … 637 633 } 638 634 639 bool Core::preUpdate(const Clock& time) throw() 640 { 641 std::string exceptionMessage; 642 try 643 { 644 if (this->bGraphicsLoaded_) 645 { 646 // process input events 647 this->inputManager_->update(time); 648 // process gui events 649 this->guiManager_->update(time); 650 } 651 // process thread commands 652 this->tclThreadManager_->update(time); 653 } 654 catch (const std::exception& ex) 655 { exceptionMessage = ex.what(); } 656 catch (...) 657 { exceptionMessage = "Unknown exception"; } 658 if (!exceptionMessage.empty()) 659 { 660 COUT(0) << "An exception occurred in the Core preUpdate: " << exceptionMessage << std::endl; 661 COUT(0) << "This should really never happen! Closing the program." << std::endl; 662 return false; 663 } 664 return true; 665 } 666 667 bool Core::postUpdate(const Clock& time) throw() 668 { 669 std::string exceptionMessage; 670 try 671 { 672 if (this->bGraphicsLoaded_) 673 { 674 // Render (doesn't throw) 675 this->graphicsManager_->update(time); 676 } 677 } 678 catch (const std::exception& ex) 679 { exceptionMessage = ex.what(); } 680 catch (...) 681 { exceptionMessage = "Unknown exception"; } 682 if (!exceptionMessage.empty()) 683 { 684 COUT(0) << "An exception occurred in the Core postUpdate: " << exceptionMessage << std::endl; 685 COUT(0) << "This should really never happen! Closing the program." << std::endl; 686 return false; 687 } 688 return true; 635 void Core::preUpdate(const Clock& time) 636 { 637 if (this->bGraphicsLoaded_) 638 { 639 // process input events 640 this->inputManager_->update(time); 641 // process gui events 642 this->guiManager_->update(time); 643 } 644 // process thread commands 645 this->tclThreadManager_->update(time); 646 } 647 648 void Core::postUpdate(const Clock& time) 649 { 650 if (this->bGraphicsLoaded_) 651 { 652 // Render (doesn't throw) 653 this->graphicsManager_->update(time); 654 } 689 655 } 690 656 }
Note: See TracChangeset
for help on using the changeset viewer.