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/Orxonox.cc

    r1028 r1032  
    2727
    2828/**
    29  @file  Orxonox.cc
     29 @file
    3030 @brief Orxonox Main Class
    3131 */
     
    3333// Precompiled Headers
    3434#include "OrxonoxStableHeaders.h"
     35
     36//****** STD *******
     37//#include <iostream>
     38//#include <exception>
     39#include <deque>
    3540
    3641//****** OGRE ******
     
    3944#include <OgreOverlay.h>
    4045#include <OgreOverlayManager.h>
     46#include <OgreRoot.h>
    4147#include <OgreTimer.h>
    4248#include <OgreWindowEventUtilities.h>
    4349
    44 //****** STD *******
    45 //#include <iostream>
    46 //#include <exception>
    47 #include <deque>
    48 
    4950//***** ORXONOX ****
    50 //misc
     51// util
    5152//#include "util/Sleep.h"
    5253#include "util/ArgReader.h"
    5354
    54 // audio
    55 #include "audio/AudioManager.h"
    56 
    57 // network
    58 #include "network/Server.h"
    59 #include "network/Client.h"
    60 network::Client *client_g;
    61 network::Server *server_g;
    62 
    63 // objects
     55// core
    6456#include "core/Debug.h"
    6557#include "core/Factory.h"
    6658#include "core/Loader.h"
    6759#include "core/Tickable.h"
     60#include "core/InputManager.h"
     61
     62// audio
     63#include "audio/AudioManager.h"
     64
     65// network
     66#include "network/Server.h"
     67#include "network/Client.h"
     68
     69// objects and tools
     70#include "tools/Timer.h"
    6871#include "hud/HUD.h"
    69 #include "tools/Timer.h"
    70 #include "objects/weapon/BulletManager.h"
    71 
    72 #include "core/InputManager.h"
     72//#include "objects/weapon/BulletManager.h"
    7373
    7474#include "Orxonox.h"
     75
     76// FIXME: is this really file scope?
     77// globals for the server or client
     78network::Client *client_g;
     79network::Server *server_g;
    7580
    7681namespace orxonox
     
    8691  Orxonox::Orxonox()
    8792  {
    88     this->ogre_ = new GraphicsEngine();
     93    this->ogre_ = &GraphicsEngine::getSingleton();
    8994    this->timer_ = 0;
    9095    this->dataPath_ = "";
     
    103108  {
    104109    // keep in mind: the order of deletion is very important!
    105     if (this->bulletMgr_)
    106       delete this->bulletMgr_;
     110//    if (this->bulletMgr_)
     111//      delete this->bulletMgr_;
    107112    if (this->orxonoxHUD_)
    108113      delete this->orxonoxHUD_;
     
    113118    if (this->timer_)
    114119      delete this->timer_;
    115     if (this->ogre_)
    116       delete this->ogre_;
     120    GraphicsEngine::getSingleton().destroy();
    117121
    118122    if (client_g)
     
    251255    auMan_ = new audio::AudioManager();
    252256
    253     bulletMgr_ = new BulletManager();
     257    //bulletMgr_ = new BulletManager();
    254258   
    255259    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
     
    298302    auMan_ = new audio::AudioManager();
    299303
    300     bulletMgr_ = new BulletManager();
     304    //bulletMgr_ = new BulletManager();
    301305
    302306    // load this file from config
     
    342346    About the loop: The design is almost exactly like the one in ogre, so that
    343347    if any part of ogre registers a framelisteners, it will still behave
    344     correctly. Furthermore I have taken over the time smoothing feature from
    345     ogre. If turned on (see orxonox constructor), it will calculate the dt_n by
    346     means of the recent most dt_n-1, dt_n-2, etc.
     348    correctly. Furthermore the time smoothing feature from ogre has been
     349    implemented too. If turned on (see orxonox constructor), it will calculate
     350    the dt_n by means of the recent most dt_n-1, dt_n-2, etc.
    347351  */
    348352  void Orxonox::startRenderLoop()
    349353  {
     354    // first check whether ogre root object has been created
     355    if (Ogre::Root::getSingletonPtr() == 0)
     356    {
     357      COUT(2) << "Error: Could not start rendering. No Ogre root object found" << std::endl;
     358      return;
     359    }
     360
    350361    // Contains the times of recently fired events
    351362    // eventTimes[4] is the list for the times required for the fps counter
     
    389400      // don't forget to call _fireFrameStarted in ogre to make sure
    390401      // everything goes smoothly
    391       ogre_->frameStarted(evt);
     402      Ogre::Root::getSingleton()._fireFrameStarted(evt);
    392403
    393404      // server still renders at the moment
    394405      //if (mode_ != SERVER)
    395       ogre_->renderOneFrame(); // only render in non-server mode
     406      Ogre::Root::getSingleton()._updateAllRenderTargets(); // only render in non-server mode
    396407
    397408      // get current time
     
    403414
    404415      // again, just to be sure ogre works fine
    405       ogre_->frameEnded(evt);
     416      Ogre::Root::getSingleton()._fireFrameEnded(evt);
    406417          }
    407418  }
Note: See TracChangeset for help on using the changeset viewer.