Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/src/orxonox/Main.cc @ 2799

Last change on this file since 2799 was 2799, checked in by rgrieder, 15 years ago

Moved all core related initialisations from Main.cc and GSRoot.cc to Core.cc so that everything sticks together more obviously.

Renamed —directory command line argument: Name really doesn't say what it is.
using —writingPathSuffix now. Not much better, but at least you wonder

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
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.
33  */
34
35#include "OrxonoxStableHeaders.h"
36#include "OrxonoxConfig.h"
37
38#include <exception>
39#include <cassert>
40
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
83int main(int argc, char** argv)
84{
85    orxonox::Core* core = new orxonox::Core(argc, argv);
86    if (!core->isLoaded())
87    {
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;
120
121    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
122    // Needs to be done after 'delete core' because of ~OrxonoxClass
123    orxonox::Identifier::destroyAllIdentifiers();
124
125    return 0;
126}
Note: See TracBrowser for help on using the repository browser.