[612] | 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 | /** |
---|
[934] | 29 | @file |
---|
| 30 | @brief Entry point of the program. Platform specific code. |
---|
[612] | 31 | */ |
---|
| 32 | |
---|
[786] | 33 | #include "OrxonoxStableHeaders.h" |
---|
[784] | 34 | |
---|
[934] | 35 | #include <exception> |
---|
[612] | 36 | |
---|
[934] | 37 | #include "OrxonoxPlatform.h" |
---|
[612] | 38 | #include "core/SignalHandler.h" |
---|
[614] | 39 | #include "Orxonox.h" |
---|
[612] | 40 | |
---|
| 41 | using namespace orxonox; |
---|
[934] | 42 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
[612] | 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 |
---|
| 70 | extern "C" { |
---|
| 71 | #endif |
---|
| 72 | |
---|
[934] | 73 | int main(int argc, char **argv) |
---|
[622] | 74 | { |
---|
[934] | 75 | try { |
---|
[612] | 76 | SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log"); |
---|
| 77 | Orxonox* orx = Orxonox::getSingleton(); |
---|
[934] | 78 | |
---|
| 79 | #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE |
---|
[612] | 80 | orx->init(argc, argv, macBundlePath()); |
---|
| 81 | #else |
---|
| 82 | orx->init(argc, argv, ""); |
---|
| 83 | #endif |
---|
| 84 | |
---|
[934] | 85 | orx->start(); |
---|
| 86 | orx->destroy(); |
---|
[612] | 87 | } |
---|
[934] | 88 | catch (std::exception &ex) |
---|
[612] | 89 | { |
---|
[934] | 90 | std::cerr << "Exception:\n"; |
---|
| 91 | std::cerr << ex.what() << "\n"; |
---|
[612] | 92 | return 1; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | return 0; |
---|
| 96 | } |
---|
| 97 | |
---|
[934] | 98 | #ifdef __cplusplus |
---|
| 99 | } |
---|
| 100 | #endif |
---|