Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 12, 2008, 4:08:29 PM (16 years ago)
Author:
rgrieder
Message:
  • singletonized GraphicsEngine —> Orxonox.h has to included only twice —> better compile performance —> Everything graphic related can now be accessed with GraphicsEngine::getSingleton()
  • asylumized Fighter (SpaceShip with weapon system integrated)
  • removed weapon system from build
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1024 r1032  
    2222 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
    2323 *   Co-authors:
    24  *      ...
     24 *      Reto Grieder
    2525 *
    2626 */
     
    4141#include "core/CoreIncludes.h"
    4242#include "core/Debug.h"
     43
    4344#include "GraphicsEngine.h"
    4445
     
    4849  using namespace Ogre;
    4950
     51  /**
     52    @brief Returns the singleton instance and creates it the first time.
     53    @return The only instance of GraphicsEngine.
     54  */
     55  GraphicsEngine& GraphicsEngine::getSingleton()
     56  {
     57    static GraphicsEngine theOnlyInstance;
     58    return theOnlyInstance;
     59  }
     60
     61  /**
     62    @brief Only use constructor to initialise variables and pointers!
     63  */
    5064  GraphicsEngine::GraphicsEngine()
    5165  {
     
    5872    this->scene_ = 0;
    5973    this->renderWindow_ = 0;
    60   }
    61 
    62 
     74    COUT(4) << "*** GraphicsEngine: Constructed" << std::endl;
     75  }
     76
     77  /**
     78    @brief Called after main() --> call destroyObjects()!
     79  */
    6380  GraphicsEngine::~GraphicsEngine()
    6481  {
     82    this->destroy();
     83  }
     84
     85  /**
     86    @brief Destroys all the internal objects. Call this method when you
     87           normally would call the destructor.
     88  */
     89  void GraphicsEngine::destroy()
     90  {
     91    COUT(4) << "*** GraphicsEngine: Destroying objects..." << std::endl;
    6592    if (this->root_)
    6693      delete this->root_;
    67     // delete the ogre log and the logManager (sine we have created it).
     94    this->root_ = 0;
     95    this->scene_ = 0;
     96    this->renderWindow_ = 0;
     97    // delete the ogre log and the logManager (since we have created it).
    6898    if (LogManager::getSingletonPtr() != 0)
    6999    {
     
    72102      delete LogManager::getSingletonPtr();
    73103    }
     104    COUT(4) << "*** GraphicsEngine: Destroying objects done" << std::endl;
    74105  }
    75106
     
    78109    SetConfigValue(dataPath_, "../../media/").description("relative path to media data");
    79110    SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
    80     SetConfigValue(ogreLogLevelTrivial_ , 5).description("relative path to media data");
    81     SetConfigValue(ogreLogLevelNormal_  , 4).description("relative path to media data");
    82     SetConfigValue(ogreLogLevelCritical_, 2).description("relative path to media data");
     111    SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
     112    SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
     113    SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
    83114  }
    84115
     
    107138    else
    108139      logger = LogManager::getSingletonPtr();
     140    COUT(4) << "*** GraphicsEngine: Ogre LogManager created/assigned" << std::endl;
    109141
    110142    // create our own log that we can listen to
     
    114146    else
    115147      myLog = logger->createLog(this->ogreLogfile_, true, false, false);
     148    COUT(4) << "*** GraphicsEngine: Ogre Log created" << std::endl;
    116149
    117150    myLog->setLogDetail(LL_BOREME);
     
    119152
    120153    // Root will detect that we've already created a Log
     154    COUT(4) << "*** GraphicsEngine: Creating Ogre Root..." << std::endl;
    121155    root_ = new Root(plugin_filename);
     156    COUT(4) << "*** GraphicsEngine: Creating Ogre Root done" << std::endl;
    122157  }
    123158
     
    192227    if (this->renderWindow_)
    193228    {
    194       Ogre::RenderWindow *renderWindow = this->root_->getAutoCreatedWindow();
    195229      size_t windowHnd = 0;
    196       renderWindow->getCustomAttribute("WINDOW", &windowHnd);
     230      this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
    197231      return windowHnd;
    198232    }
     
    208242  {
    209243    if (this->renderWindow_)
    210     {
    211244      return this->renderWindow_->getWidth();
    212     }
    213245    else
    214246      return 0;
     
    222254  {
    223255    if (this->renderWindow_)
    224     {
    225256      return this->renderWindow_->getHeight();
    226     }
    227257    else
    228258      return 0;
Note: See TracChangeset for help on using the changeset viewer.