Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/Main.cc @ 1045

Last change on this file since 1045 was 1024, checked in by rgrieder, 17 years ago

merged input back into trunk
note: I have created an asylum with obsolete code, please check the files

File size: 2.5 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
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (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, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28 /**
29 @file
30 @brief Entry point of the program. Platform specific code.
31  */
32
33#include "OrxonoxStableHeaders.h"
34
35#include <exception>
36
37#include "OrxonoxPlatform.h"
38#include "core/SignalHandler.h"
39#include "Orxonox.h"
40
41using namespace orxonox;
42#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
43#include <CoreFoundation/CoreFoundation.h>
44
45// This function will locate the path to our application on OS X,
46// unlike windows you can not rely on the curent working directory
47// for locating your configuration files and resources.
48             std::string macBundlePath()
49{
50  char path[1024];
51  CFBundleRef mainBundle = CFBundleGetMainBundle();
52  assert(mainBundle);
53
54  CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
55  assert(mainBundleURL);
56
57  CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
58  assert(cfStringRef);
59
60  CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
61
62  CFRelease(mainBundleURL);
63  CFRelease(cfStringRef);
64
65  return std::string(path);
66}
67#endif
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73int main(int argc, char **argv)
74{
75  try {
76    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
77    Orxonox* orx = Orxonox::getSingleton();
78
79#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
80    orx->init(argc, argv, macBundlePath());
81#else
82    orx->init(argc, argv, "");
83#endif
84
85    orx->start();
86    orx->destroySingleton();
87  }
88  catch (std::exception &ex)
89  {
90    std::cerr << "Exception:\n";
91    std::cerr << ex.what() << "\n";
92    return 1;
93  }
94
95  return 0;
96}
97
98#ifdef __cplusplus
99}
100#endif
Note: See TracBrowser for help on using the repository browser.