Changeset 2844 for code/branches/gui/src/orxonox/Main.cc
- Timestamp:
- Mar 25, 2009, 5:23:00 PM (16 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/orxonox/Main.cc
r2801 r2844 36 36 #include "OrxonoxConfig.h" 37 37 38 #include <exception> 39 #include <cassert> 38 #include "util/Debug.h" 39 #include "core/Identifier.h" 40 #include "core/Game.h" 40 41 41 #include "util/Debug.h" 42 #include "core/Core.h" 43 #include "core/Identifier.h" 44 45 #include "gamestates/GSRoot.h" 46 #include "gamestates/GSGraphics.h" 47 #include "gamestates/GSStandalone.h" 48 #include "gamestates/GSServer.h" 49 #include "gamestates/GSClient.h" 50 #include "gamestates/GSDedicated.h" 51 #include "gamestates/GSGUI.h" 52 #include "gamestates/GSIOConsole.h" 53 54 #ifdef ORXONOX_PLATFORM_APPLE 55 #include <CoreFoundation/CoreFoundation.h> 56 57 // This function will locate the path to our application on OS X, 58 // unlike windows you can not rely on the curent working directory 59 // for locating your configuration files and resources. 60 std::string macBundlePath() 61 { 62 char path[1024]; 63 CFBundleRef mainBundle = CFBundleGetMainBundle(); 64 assert(mainBundle); 65 66 CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); 67 assert(mainBundleURL); 68 69 CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); 70 assert(cfStringRef); 71 72 CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); 73 74 CFRelease(mainBundleURL); 75 CFRelease(cfStringRef); 76 77 return std::string(path); 78 } 79 #endif 80 81 82 42 /* 43 @brief 44 Main method. Game starts here (except for static initialisations). 45 */ 83 46 int main(int argc, char** argv) 84 47 { 85 orxonox::Core* core = new orxonox::Core(argc, argv);86 if (!core->isLoaded())87 48 { 88 COUT(0) << "Core was not fully loaded, probably an exception occurred during consruction. Aborting" << std::endl; 89 abort(); 90 } 91 92 // put GameStates in its own scope so we can destroy the identifiers at the end of main(). 93 { 94 using namespace orxonox; 95 // create the gamestates 96 GSRoot root; 97 GSGraphics graphics; 98 GSStandalone standalone; 99 GSServer server; 100 GSClient client; 101 GSDedicated dedicated; 102 GSGUI gui; 103 GSIOConsole ioConsole; 104 105 // make the hierarchy 106 root.addChild(&graphics); 107 graphics.addChild(&standalone); 108 graphics.addChild(&server); 109 graphics.addChild(&client); 110 graphics.addChild(&gui); 111 root.addChild(&ioConsole); 112 root.addChild(&dedicated); 113 114 // Here happens the game 115 root.start(); 116 } 117 118 // Destroy pretty much everyhting left 119 delete core; 49 orxonox::Game orxonox(argc, argv); 50 orxonox.run(); 51 } // orxonox gets destroyed right here! 120 52 121 53 // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand) 122 // Needs to be done after 'delete core'because of ~OrxonoxClass54 // Needs to be done after Game destructor because of ~OrxonoxClass 123 55 orxonox::Identifier::destroyAllIdentifiers(); 124 56
Note: See TracChangeset
for help on using the changeset viewer.