| [74] | 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 | *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 | 
|---|
|  | 23 | *   Co-authors: | 
|---|
|  | 24 | *      ... | 
|---|
|  | 25 | * | 
|---|
|  | 26 | */ | 
|---|
|  | 27 |  | 
|---|
| [142] | 28 | /** | 
|---|
|  | 29 | @file  orxonox.cc | 
|---|
|  | 30 | @brief Orxonox Main File | 
|---|
|  | 31 | */ | 
|---|
|  | 32 |  | 
|---|
| [379] | 33 | //#include <Ogre.h> | 
|---|
|  | 34 | // 40% speed up: (instead of Ogre.h) | 
|---|
|  | 35 | #include <OgreSceneNode.h> | 
|---|
|  | 36 | #include <OgreSceneManager.h> | 
|---|
|  | 37 | #include <OgreRoot.h> | 
|---|
|  | 38 | #include <OgreFrameListener.h> | 
|---|
|  | 39 | #include <OgreConfigFile.h> | 
|---|
|  | 40 | #include <OgreTextureManager.h> | 
|---|
|  | 41 | #include <OgreEntity.h> | 
|---|
|  | 42 | #include <OgreRenderWindow.h> | 
|---|
|  | 43 |  | 
|---|
| [137] | 44 | #include <OIS/OIS.h> | 
|---|
| [346] | 45 | //#include <CEGUI/CEGUI.h> | 
|---|
|  | 46 | //#include <OgreCEGUIRenderer.h> | 
|---|
| [74] | 47 |  | 
|---|
| [164] | 48 | #include <string> | 
|---|
|  | 49 | #include <iostream> | 
|---|
|  | 50 |  | 
|---|
| [337] | 51 | #include "xml/xmlParser.h" | 
|---|
|  | 52 | #include "loader/LevelLoader.h" | 
|---|
| [389] | 53 | #include "audio/AudioManager.h" | 
|---|
| [164] | 54 |  | 
|---|
| [337] | 55 | #include "spaceship_steering.h" | 
|---|
|  | 56 | SpaceshipSteering* steering; | 
|---|
| [164] | 57 |  | 
|---|
| [419] | 58 | audio::AudioManager* auMan; | 
|---|
| [337] | 59 |  | 
|---|
| [151] | 60 | // some tests to see if enet works without includsion | 
|---|
|  | 61 | //#include <enet/enet.h> | 
|---|
|  | 62 | //#include <enet/protocol.h> | 
|---|
| [142] | 63 |  | 
|---|
| [137] | 64 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE | 
|---|
|  | 65 | #include <CoreFoundation/CoreFoundation.h> | 
|---|
| [74] | 66 |  | 
|---|
| [137] | 67 | // This function will locate the path to our application on OS X, | 
|---|
|  | 68 | // unlike windows you can not rely on the curent working directory | 
|---|
|  | 69 | // for locating your configuration files and resources. | 
|---|
|  | 70 | std::string macBundlePath() | 
|---|
| [74] | 71 | { | 
|---|
| [137] | 72 | char path[1024]; | 
|---|
|  | 73 | CFBundleRef mainBundle = CFBundleGetMainBundle(); | 
|---|
|  | 74 | assert(mainBundle); | 
|---|
|  | 75 |  | 
|---|
|  | 76 | CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); | 
|---|
|  | 77 | assert(mainBundleURL); | 
|---|
|  | 78 |  | 
|---|
|  | 79 | CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); | 
|---|
|  | 80 | assert(cfStringRef); | 
|---|
|  | 81 |  | 
|---|
|  | 82 | CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); | 
|---|
|  | 83 |  | 
|---|
|  | 84 | CFRelease(mainBundleURL); | 
|---|
|  | 85 | CFRelease(cfStringRef); | 
|---|
|  | 86 |  | 
|---|
|  | 87 | return std::string(path); | 
|---|
|  | 88 | } | 
|---|
|  | 89 | #endif | 
|---|
|  | 90 |  | 
|---|
| [337] | 91 | namespace orxonox | 
|---|
|  | 92 | { | 
|---|
| [74] | 93 |  | 
|---|
| [337] | 94 | using namespace Ogre; | 
|---|
|  | 95 |  | 
|---|
|  | 96 | class OrxExitListener : public FrameListener, public OIS::MouseListener | 
|---|
|  | 97 | { | 
|---|
|  | 98 | public: | 
|---|
|  | 99 | OrxExitListener(OIS::Keyboard *keyboard, OIS::Mouse *mouse) | 
|---|
|  | 100 | : mKeyboard(keyboard), mMouse(mouse) | 
|---|
|  | 101 | { | 
|---|
|  | 102 | speed = 250; | 
|---|
|  | 103 | loop = 100; | 
|---|
|  | 104 | rotate = 10; | 
|---|
|  | 105 | mouseX = 0; | 
|---|
|  | 106 | mouseY = 0; | 
|---|
|  | 107 | maxMouseX = 0; | 
|---|
|  | 108 | minMouseX = 0; | 
|---|
|  | 109 | moved = false; | 
|---|
|  | 110 | steering->brakeRotate(rotate*10); | 
|---|
|  | 111 | steering->brakeLoop(loop); | 
|---|
|  | 112 | mMouse->setEventCallback(this); | 
|---|
|  | 113 | } | 
|---|
|  | 114 | bool frameStarted(const FrameEvent& evt) | 
|---|
|  | 115 | { | 
|---|
| [458] | 116 |  | 
|---|
| [419] | 117 | auMan->update(); | 
|---|
| [458] | 118 |  | 
|---|
| [337] | 119 | mKeyboard->capture(); | 
|---|
|  | 120 | mMouse->capture(); | 
|---|
|  | 121 | if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) | 
|---|
|  | 122 | steering->moveForward(speed); | 
|---|
|  | 123 | else | 
|---|
|  | 124 | steering->moveForward(0); | 
|---|
|  | 125 | if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S)) | 
|---|
|  | 126 | steering->brakeForward(speed); | 
|---|
|  | 127 | else | 
|---|
|  | 128 | steering->brakeForward(speed/10); | 
|---|
|  | 129 | if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D)) | 
|---|
|  | 130 | steering->loopRight(loop); | 
|---|
|  | 131 | else | 
|---|
|  | 132 | steering->loopRight(0); | 
|---|
|  | 133 | if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A)) | 
|---|
|  | 134 | steering->loopLeft(loop); | 
|---|
|  | 135 | else | 
|---|
|  | 136 | steering->loopLeft(0); | 
|---|
|  | 137 |  | 
|---|
|  | 138 | if(moved) { | 
|---|
|  | 139 | if (mouseY<0) | 
|---|
|  | 140 | steering->rotateUp(-mouseY*rotate); | 
|---|
|  | 141 | if (mouseY>0) | 
|---|
|  | 142 | steering->rotateDown(mouseY*rotate); | 
|---|
|  | 143 | if (mouseX>0) | 
|---|
|  | 144 | steering->rotateRight(mouseX*rotate); | 
|---|
|  | 145 | if (mouseX<0) | 
|---|
|  | 146 | steering->rotateLeft(-mouseX*rotate); | 
|---|
|  | 147 | moved = false; | 
|---|
| [265] | 148 | } | 
|---|
| [337] | 149 | else { | 
|---|
|  | 150 | steering->rotateUp(0); | 
|---|
|  | 151 | steering->rotateDown(0); | 
|---|
|  | 152 | steering->rotateRight(0); | 
|---|
|  | 153 | steering->rotateLeft(0); | 
|---|
|  | 154 | } | 
|---|
| [135] | 155 |  | 
|---|
| [337] | 156 | steering->tick(evt.timeSinceLastFrame); | 
|---|
|  | 157 | //      scenemanager->spacehip->tick(evt.timesincelastframe); | 
|---|
|  | 158 | if(mKeyboard->isKeyDown(OIS::KC_ESCAPE)) | 
|---|
|  | 159 | cout << "maximal MouseX: " << maxMouseX << "\tminMouseX: " << minMouseX << endl; | 
|---|
|  | 160 | return !mKeyboard->isKeyDown(OIS::KC_ESCAPE); | 
|---|
|  | 161 | } | 
|---|
| [74] | 162 |  | 
|---|
| [337] | 163 | bool mouseMoved(const OIS::MouseEvent &e) | 
|---|
|  | 164 | { | 
|---|
|  | 165 | mouseX = e.state.X.rel; | 
|---|
|  | 166 | mouseY = e.state.Y.rel; | 
|---|
|  | 167 | if(mouseX>maxMouseX) maxMouseX = mouseX; | 
|---|
|  | 168 | if(mouseX<minMouseX) minMouseX = mouseX; | 
|---|
|  | 169 | cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl; | 
|---|
|  | 170 | moved = true; | 
|---|
|  | 171 | return true; | 
|---|
|  | 172 | } | 
|---|
|  | 173 |  | 
|---|
|  | 174 | bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; } | 
|---|
|  | 175 | bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; } | 
|---|
|  | 176 |  | 
|---|
|  | 177 | private: | 
|---|
|  | 178 | float speed; | 
|---|
|  | 179 | float rotate; | 
|---|
|  | 180 | float loop; | 
|---|
|  | 181 | float mouseY; | 
|---|
|  | 182 | float mouseX; | 
|---|
|  | 183 | float maxMouseX; | 
|---|
|  | 184 | float minMouseX; | 
|---|
|  | 185 | bool moved; | 
|---|
|  | 186 | OIS::Keyboard *mKeyboard; | 
|---|
|  | 187 | OIS::Mouse *mMouse; | 
|---|
|  | 188 | }; | 
|---|
|  | 189 |  | 
|---|
|  | 190 |  | 
|---|
| [265] | 191 | class OrxApplication | 
|---|
|  | 192 | { | 
|---|
|  | 193 | public: | 
|---|
|  | 194 | void go() | 
|---|
|  | 195 | { | 
|---|
|  | 196 | createRoot(); | 
|---|
|  | 197 | defineResources(); | 
|---|
|  | 198 | setupRenderSystem(); | 
|---|
|  | 199 | createRenderWindow(); | 
|---|
|  | 200 | initializeResourceGroups(); | 
|---|
|  | 201 | createScene(); | 
|---|
|  | 202 | setupScene(); | 
|---|
|  | 203 | setupInputSystem(); | 
|---|
| [458] | 204 | //         setupCEGUI(); | 
|---|
| [265] | 205 | createFrameListener(); | 
|---|
|  | 206 | startRenderLoop(); | 
|---|
|  | 207 | } | 
|---|
| [74] | 208 |  | 
|---|
| [265] | 209 | ~OrxApplication() | 
|---|
|  | 210 | { | 
|---|
|  | 211 | mInputManager->destroyInputObject(mKeyboard); | 
|---|
|  | 212 | OIS::InputManager::destroyInputSystem(mInputManager); | 
|---|
| [137] | 213 |  | 
|---|
| [265] | 214 | //        delete mRenderer; | 
|---|
|  | 215 | //        delete mSystem; | 
|---|
| [137] | 216 |  | 
|---|
| [458] | 217 | //         delete mListener; | 
|---|
|  | 218 | //         delete mRoot; | 
|---|
| [265] | 219 | } | 
|---|
| [137] | 220 |  | 
|---|
| [265] | 221 | private: | 
|---|
|  | 222 | Ogre::Root *mRoot; | 
|---|
|  | 223 | OIS::Keyboard *mKeyboard; | 
|---|
|  | 224 | OIS::Mouse *mMouse; | 
|---|
|  | 225 | OIS::InputManager *mInputManager; | 
|---|
| [346] | 226 | //CEGUI::OgreCEGUIRenderer *mRenderer; | 
|---|
|  | 227 | //CEGUI::System *mSystem; | 
|---|
| [265] | 228 | OrxExitListener *mListener; | 
|---|
| [137] | 229 |  | 
|---|
| [265] | 230 | void createRoot() | 
|---|
|  | 231 | { | 
|---|
|  | 232 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE | 
|---|
|  | 233 | mRoot = new Ogre::Root(macBundlePath() + "/Contents/Resources/plugins.cfg"); | 
|---|
|  | 234 | #else | 
|---|
|  | 235 | mRoot = new Ogre::Root(); | 
|---|
|  | 236 | #endif | 
|---|
|  | 237 | } | 
|---|
| [74] | 238 |  | 
|---|
| [265] | 239 | void defineResources() | 
|---|
|  | 240 | { | 
|---|
|  | 241 | Ogre::String secName, typeName, archName; | 
|---|
|  | 242 | Ogre::ConfigFile cf; | 
|---|
|  | 243 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE | 
|---|
|  | 244 | cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); | 
|---|
|  | 245 | #else | 
|---|
|  | 246 | cf.load("resources.cfg"); | 
|---|
|  | 247 | #endif | 
|---|
|  | 248 |  | 
|---|
|  | 249 | Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); | 
|---|
|  | 250 | while (seci.hasMoreElements()) | 
|---|
| [263] | 251 | { | 
|---|
| [265] | 252 | secName = seci.peekNextKey(); | 
|---|
|  | 253 | Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); | 
|---|
|  | 254 | Ogre::ConfigFile::SettingsMultiMap::iterator i; | 
|---|
|  | 255 | for (i = settings->begin(); i != settings->end(); ++i) | 
|---|
| [263] | 256 | { | 
|---|
| [265] | 257 | typeName = i->first; | 
|---|
|  | 258 | archName = i->second; | 
|---|
|  | 259 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE | 
|---|
|  | 260 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName); | 
|---|
|  | 261 | #else | 
|---|
|  | 262 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); | 
|---|
|  | 263 | #endif | 
|---|
| [263] | 264 | } | 
|---|
|  | 265 | } | 
|---|
| [265] | 266 | } | 
|---|
| [263] | 267 |  | 
|---|
| [265] | 268 | void setupRenderSystem() | 
|---|
|  | 269 | { | 
|---|
|  | 270 | if (!mRoot->restoreConfig() && !mRoot->showConfigDialog()) | 
|---|
| [337] | 271 | throw Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); | 
|---|
| [265] | 272 | } | 
|---|
| [74] | 273 |  | 
|---|
| [265] | 274 | void createRenderWindow() | 
|---|
|  | 275 | { | 
|---|
| [368] | 276 | mRoot->initialise(true, "OrxonoxV2"); | 
|---|
| [265] | 277 | } | 
|---|
| [74] | 278 |  | 
|---|
| [265] | 279 | void initializeResourceGroups() | 
|---|
|  | 280 | { | 
|---|
| [337] | 281 | TextureManager::getSingleton().setDefaultNumMipmaps(5); | 
|---|
|  | 282 | ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); | 
|---|
| [265] | 283 | } | 
|---|
| [74] | 284 |  | 
|---|
| [265] | 285 | void createScene(void) | 
|---|
|  | 286 | { | 
|---|
| [419] | 287 | auMan = new audio::AudioManager(); | 
|---|
| [74] | 288 |  | 
|---|
| [430] | 289 | auMan->ambientAdd("a1"); | 
|---|
|  | 290 | auMan->ambientAdd("a2"); | 
|---|
|  | 291 | auMan->ambientAdd("a3"); | 
|---|
|  | 292 | //auMan->ambientAdd("ambient1"); | 
|---|
|  | 293 | auMan->ambientStart(); | 
|---|
| [389] | 294 |  | 
|---|
| [347] | 295 | string levelFile = "sp_level_moonstation.oxw"; | 
|---|
| [458] | 296 | //       loader::LevelLoader* loader = new loader::LevelLoader(levelFile); | 
|---|
| [337] | 297 | } | 
|---|
| [164] | 298 |  | 
|---|
| [389] | 299 |  | 
|---|
| [337] | 300 | void setupScene() | 
|---|
|  | 301 | { | 
|---|
|  | 302 | SceneManager *mgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager"); | 
|---|
|  | 303 | Camera *cam = mgr->createCamera("Camera"); | 
|---|
|  | 304 | cam->setPosition(Vector3(0,0,-250)); | 
|---|
|  | 305 | cam->lookAt(Vector3(0,0,0)); | 
|---|
|  | 306 | Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam); | 
|---|
| [258] | 307 |  | 
|---|
| [337] | 308 |  | 
|---|
|  | 309 | mgr->setAmbientLight(ColourValue(1,1,1)); | 
|---|
| [427] | 310 | Entity* head = mgr->createEntity("head", "razor.mesh"); | 
|---|
| [337] | 311 | SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0)); | 
|---|
|  | 312 | node->attachObject(head); | 
|---|
|  | 313 | node->attachObject(cam); | 
|---|
|  | 314 | mgr->setSkyBox(true, "Examples/SceneSkyBox2"); | 
|---|
|  | 315 |  | 
|---|
|  | 316 | Entity* head1 = mgr->createEntity("head1", "ogrehead.mesh"); | 
|---|
|  | 317 | SceneNode *node1 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode1", Vector3(200,0,0)); | 
|---|
|  | 318 | node1->attachObject(head1); | 
|---|
|  | 319 | Entity* head2 = mgr->createEntity("head2", "ogrehead.mesh"); | 
|---|
|  | 320 | SceneNode *node2 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode2", Vector3(200,400,-100)); | 
|---|
|  | 321 | node2->attachObject(head2); | 
|---|
|  | 322 | Entity* head3 = mgr->createEntity("head3", "ogrehead.mesh"); | 
|---|
|  | 323 | SceneNode *node3 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode3", Vector3(0,400,200)); | 
|---|
|  | 324 | node3->attachObject(head3); | 
|---|
|  | 325 | Entity* head4 = mgr->createEntity("head4", "ogrehead.mesh"); | 
|---|
|  | 326 | SceneNode *node4 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode4", Vector3(-400,-200,600)); | 
|---|
|  | 327 | node4->attachObject(head4); | 
|---|
|  | 328 | Entity* head5 = mgr->createEntity("head5", "ogrehead.mesh"); | 
|---|
|  | 329 | SceneNode *node5 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode5", Vector3(0,0,-400)); | 
|---|
|  | 330 | node5->attachObject(head5); | 
|---|
|  | 331 |  | 
|---|
|  | 332 | steering = new SpaceshipSteering(500, 200, 200, 200); | 
|---|
|  | 333 | steering->addNode(node); | 
|---|
|  | 334 |  | 
|---|
|  | 335 | } | 
|---|
|  | 336 |  | 
|---|
|  | 337 |  | 
|---|
| [265] | 338 | void setupInputSystem() | 
|---|
|  | 339 | { | 
|---|
|  | 340 | size_t windowHnd = 0; | 
|---|
|  | 341 | std::ostringstream windowHndStr; | 
|---|
|  | 342 | OIS::ParamList pl; | 
|---|
|  | 343 | Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); | 
|---|
| [74] | 344 |  | 
|---|
| [265] | 345 | win->getCustomAttribute("WINDOW", &windowHnd); | 
|---|
|  | 346 | windowHndStr << windowHnd; | 
|---|
|  | 347 | pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); | 
|---|
|  | 348 | mInputManager = OIS::InputManager::createInputSystem(pl); | 
|---|
| [74] | 349 |  | 
|---|
| [265] | 350 | try | 
|---|
|  | 351 | { | 
|---|
|  | 352 | mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false)); | 
|---|
| [337] | 353 | mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true)); | 
|---|
| [263] | 354 | } | 
|---|
| [265] | 355 | catch (const OIS::Exception &e) | 
|---|
| [263] | 356 | { | 
|---|
| [265] | 357 | throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem"); | 
|---|
|  | 358 | } | 
|---|
|  | 359 | } | 
|---|
| [74] | 360 |  | 
|---|
| [458] | 361 | //       void setupCEGUI() | 
|---|
|  | 362 | //       { | 
|---|
|  | 363 | //         Ogre::SceneManager *mgr = mRoot->getSceneManager("Default SceneManager"); | 
|---|
|  | 364 | //         Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); | 
|---|
| [137] | 365 |  | 
|---|
| [265] | 366 | // CEGUI setup | 
|---|
|  | 367 | //        mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr); | 
|---|
|  | 368 | //        mSystem = new CEGUI::System(mRenderer); | 
|---|
| [137] | 369 |  | 
|---|
| [265] | 370 | // Other CEGUI setup here. | 
|---|
| [458] | 371 | //       } | 
|---|
| [137] | 372 |  | 
|---|
| [265] | 373 |  | 
|---|
| [337] | 374 | void createFrameListener() | 
|---|
|  | 375 | { | 
|---|
|  | 376 | mListener = new OrxExitListener(mKeyboard, mMouse); | 
|---|
|  | 377 | mRoot->addFrameListener(mListener); | 
|---|
|  | 378 | } | 
|---|
| [265] | 379 | void startRenderLoop() | 
|---|
|  | 380 | { | 
|---|
|  | 381 | mRoot->startRendering(); | 
|---|
|  | 382 | } | 
|---|
|  | 383 | }; | 
|---|
| [337] | 384 | } | 
|---|
| [137] | 385 |  | 
|---|
| [337] | 386 | using namespace Ogre; | 
|---|
|  | 387 |  | 
|---|
| [137] | 388 | #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 | 
|---|
| [74] | 389 | #define WIN32_LEAN_AND_MEAN | 
|---|
|  | 390 | #include "windows.h" | 
|---|
|  | 391 |  | 
|---|
| [137] | 392 | INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) | 
|---|
| [74] | 393 | #else | 
|---|
| [137] | 394 | int main(int argc, char **argv) | 
|---|
| [74] | 395 | #endif | 
|---|
|  | 396 | { | 
|---|
| [137] | 397 | try | 
|---|
|  | 398 | { | 
|---|
| [263] | 399 | orxonox::OrxApplication orxonox; | 
|---|
| [74] | 400 | orxonox.go(); | 
|---|
| [137] | 401 | } | 
|---|
|  | 402 | catch(Exception& e) | 
|---|
|  | 403 | { | 
|---|
|  | 404 | #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 | 
|---|
|  | 405 | MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); | 
|---|
| [74] | 406 | #else | 
|---|
|  | 407 | fprintf(stderr, "An exception has occurred: %s\n", | 
|---|
|  | 408 | e.getFullDescription().c_str()); | 
|---|
|  | 409 | #endif | 
|---|
|  | 410 | } | 
|---|
|  | 411 |  | 
|---|
|  | 412 | return 0; | 
|---|
|  | 413 | } | 
|---|
| [137] | 414 |  | 
|---|