Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/main_reto/src/orxonox.cc @ 171

Last change on this file since 171 was 171, checked in by rgrieder, 17 years ago
  • added all my own files in the src directory
  • edited CMakeLists.txt in the src folder to match my files
File size: 2.4 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software: you can redistribute it and/or modify
8 *   it under the terms of the GNU General Public License as published by
9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 *   Author:
22 *      Reto Grieder
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28/**
29* Basic part of the game.
30* It sets up Ogre and most important of all: Orxonox is the master of the
31* main loop and therefore time itself.
32*/
33
34#include "OgreRoot.h"
35#include "OgreTimer.h"
36#include "OgreWindowEventUtilities.h"
37
38#include "ogre_control.h"
39#include "run_manager.h"
40#include "orxonox.h"
41
42
43namespace orxonox {
44
45  /**
46  * Empty Constructor.
47  */
48  Orxonox::Orxonox()
49  {
50  }
51
52
53  /**
54  * Empty Destructor.
55  */
56  Orxonox::~Orxonox()
57  {
58  }
59
60
61  /**
62  * Starts and runs the game
63  */
64  void Orxonox::go(void)
65  {
66          if (!setup())
67                  return;
68
69    timer_ = new Ogre::Timer();
70
71          unsigned long lastTime = timer_->getMilliseconds();
72
73          while (true)
74          {
75                  //Pump messages in all registered RenderWindow windows
76      Ogre::WindowEventUtilities::messagePump();
77
78                  ogre_->getRoot()->renderOneFrame();
79
80                  if (!runMgr_->tick(timer_->getMilliseconds(),
81              (timer_->getMilliseconds() - lastTime) / 1000.0))
82                          break;
83                  lastTime = timer_->getMilliseconds();
84          }
85
86          // clean up
87          destroy();
88  }
89
90
91  /**
92  * Create render engine, render window and the Run manager.
93  * @return False if failed.
94  */
95  bool Orxonox::setup(void)
96  {
97          // create new 3D ogre render engine
98          ogre_ = new OgreControl();
99          ogre_->initialise();
100
101          runMgr_ = new RunManager(ogre_);
102
103          return true;
104  }
105
106
107  /**
108  * Clean everything up.
109  */
110  void Orxonox::destroy()
111  {
112          if (timer_)
113                  delete timer_;
114          if (runMgr_)
115                  delete runMgr_;
116          if (ogre_)
117                  delete ogre_;
118  }
119
120}
Note: See TracBrowser for help on using the repository browser.