| 1 | /* |
|---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
|---|
| 3 | * > www.orxonox.net < |
|---|
| 4 | * |
|---|
| 5 | * |
|---|
| 6 | * License notice: |
|---|
| 7 | * |
|---|
| 8 | * This program is free software; you can redistribute it and/or |
|---|
| 9 | * modify it under the terms of the GNU General Public License |
|---|
| 10 | * as published by the Free Software Foundation; either version 2 |
|---|
| 11 | * of the License, or (at your option) any later version. |
|---|
| 12 | * |
|---|
| 13 | * This program is distributed in the hope that it will be useful, |
|---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | * GNU General Public License for more details. |
|---|
| 17 | * |
|---|
| 18 | * You should have received a copy of the GNU General Public License |
|---|
| 19 | * along with this program; if not, write to the Free Software |
|---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|---|
| 21 | * |
|---|
| 22 | * Author: |
|---|
| 23 | * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 |
|---|
| 24 | * Reto Grieder |
|---|
| 25 | * Co-authors: |
|---|
| 26 | * ... |
|---|
| 27 | * |
|---|
| 28 | */ |
|---|
| 29 | |
|---|
| 30 | /** |
|---|
| 31 | @file |
|---|
| 32 | @brief Entry point of the program. Platform specific code. |
|---|
| 33 | */ |
|---|
| 34 | |
|---|
| 35 | #include "OrxonoxStableHeaders.h" |
|---|
| 36 | |
|---|
| 37 | #include <exception> |
|---|
| 38 | #include <cassert> |
|---|
| 39 | |
|---|
| 40 | #include "util/OrxonoxPlatform.h" |
|---|
| 41 | #include "core/SignalHandler.h" |
|---|
| 42 | #include "core/Debug.h" |
|---|
| 43 | |
|---|
| 44 | #include "gamestates/GSRoot.h" |
|---|
| 45 | #include "gamestates/GSGraphics.h" |
|---|
| 46 | #include "gamestates/GSStandalone.h" |
|---|
| 47 | #include "gamestates/GSServer.h" |
|---|
| 48 | #include "gamestates/GSClient.h" |
|---|
| 49 | #include "gamestates/GSGUI.h" |
|---|
| 50 | #include "gamestates/GSIO.h" |
|---|
| 51 | #include "gamestates/GSIOConsole.h" |
|---|
| 52 | |
|---|
| 53 | using namespace orxonox; |
|---|
| 54 | |
|---|
| 55 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
|---|
| 56 | #include <CoreFoundation/CoreFoundation.h> |
|---|
| 57 | |
|---|
| 58 | // This function will locate the path to our application on OS X, |
|---|
| 59 | // unlike windows you can not rely on the curent working directory |
|---|
| 60 | // for locating your configuration files and resources. |
|---|
| 61 | std::string macBundlePath() |
|---|
| 62 | { |
|---|
| 63 | char path[1024]; |
|---|
| 64 | CFBundleRef mainBundle = CFBundleGetMainBundle(); |
|---|
| 65 | assert(mainBundle); |
|---|
| 66 | |
|---|
| 67 | CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); |
|---|
| 68 | assert(mainBundleURL); |
|---|
| 69 | |
|---|
| 70 | CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); |
|---|
| 71 | assert(cfStringRef); |
|---|
| 72 | |
|---|
| 73 | CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); |
|---|
| 74 | |
|---|
| 75 | CFRelease(mainBundleURL); |
|---|
| 76 | CFRelease(cfStringRef); |
|---|
| 77 | |
|---|
| 78 | return std::string(path); |
|---|
| 79 | } |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | //#ifdef __cplusplus |
|---|
| 84 | //extern "C" { |
|---|
| 85 | //#endif |
|---|
| 86 | |
|---|
| 87 | int main(int argc, char** argv) |
|---|
| 88 | { |
|---|
| 89 | // create a signal handler (only works for linux) |
|---|
| 90 | SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log"); |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | /*GameState* state1 = new GameState("state1"); |
|---|
| 94 | GameState* state2 = new GameState("state2"); |
|---|
| 95 | GameState* state3 = new GameState("state3"); |
|---|
| 96 | GameState* state4 = new GameState("state4"); |
|---|
| 97 | GameState* state5 = new GameState("state5"); |
|---|
| 98 | GameState* state6 = new GameState("state6"); |
|---|
| 99 | |
|---|
| 100 | state1->addChild(state4); |
|---|
| 101 | state1->addChild(state6); |
|---|
| 102 | state2->addChild(state3); |
|---|
| 103 | state2->addChild(state5); |
|---|
| 104 | state6->addChild(state2); |
|---|
| 105 | |
|---|
| 106 | state6->removeChild("state2"); |
|---|
| 107 | |
|---|
| 108 | state5->requestState("state3"); |
|---|
| 109 | COUT(2) << std::endl; |
|---|
| 110 | state2->requestState("state2"); |
|---|
| 111 | COUT(2) << std::endl; |
|---|
| 112 | state2->requestState("state1"); |
|---|
| 113 | COUT(2) << std::endl; |
|---|
| 114 | state4->requestState("state3"); |
|---|
| 115 | COUT(2) << std::endl; |
|---|
| 116 | state1->requestState("state4"); |
|---|
| 117 | COUT(2) << std::endl; |
|---|
| 118 | state1->requestState("state2"); |
|---|
| 119 | COUT(2) << std::endl; |
|---|
| 120 | state1->requestState("stat"); |
|---|
| 121 | COUT(2) << std::endl; |
|---|
| 122 | state1->requestState("state5"); |
|---|
| 123 | COUT(2) << std::endl;*/ |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | GSRoot root; |
|---|
| 127 | GSGraphics graphics; |
|---|
| 128 | GSStandalone standalone; |
|---|
| 129 | GSServer server; |
|---|
| 130 | GSClient client; |
|---|
| 131 | GSGUI gui; |
|---|
| 132 | GSIO io; |
|---|
| 133 | GSIOConsole ioConsole; |
|---|
| 134 | |
|---|
| 135 | root.addChild(&graphics); |
|---|
| 136 | graphics.addChild(&standalone); |
|---|
| 137 | graphics.addChild(&server); |
|---|
| 138 | graphics.addChild(&client); |
|---|
| 139 | graphics.addChild(&gui); |
|---|
| 140 | |
|---|
| 141 | root.addChild(&io); |
|---|
| 142 | io.addChild(&ioConsole); |
|---|
| 143 | |
|---|
| 144 | root.feedCommandLine(argc, argv); |
|---|
| 145 | root.start(); |
|---|
| 146 | |
|---|
| 147 | return 0; |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | //#ifdef __cplusplus |
|---|
| 151 | //} |
|---|
| 152 | //#endif |
|---|