Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/main.cc @ 482

Last change on this file since 482 was 473, checked in by bknecht, 17 years ago

should work again, sorry

File size: 2.7 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  main.cc
30 @brief main file handling most of the machine specific code
31  */
32
33#include <OgrePlatform.h>
34#include <OgreException.h>
35
36
37#include "orxonox.h"
38
39using namespace orxonox;
40using namespace Ogre;
41#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
42#include <CoreFoundation/CoreFoundation.h>
43
44// This function will locate the path to our application on OS X,
45// unlike windows you can not rely on the curent working directory
46// for locating your configuration files and resources.
47             std::string macBundlePath()
48{
49  char path[1024];
50  CFBundleRef mainBundle = CFBundleGetMainBundle();
51  assert(mainBundle);
52
53  CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
54  assert(mainBundleURL);
55
56  CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
57  assert(cfStringRef);
58
59  CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
60
61  CFRelease(mainBundleURL);
62  CFRelease(cfStringRef);
63
64  return std::string(path);
65}
66#endif
67
68#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
69#define WIN32_LEAN_AND_MEAN
70#include "windows.h"
71
72             INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
73#else
74
75             int main(int argc, char **argv)
76#endif
77{
78  try
79  {
80    Orxonox* orx = Orxonox::getSingleton();
81#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
82    orx->init(argc, argv, macBundlePath());
83    //orx->start();
84#else
85    orx->init(argc, argv, "");
86    //orx->start();
87#endif
88
89  }
90  catch(Ogre::Exception& e)
91  {
92#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
93    MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
94#else
95    fprintf(stderr, "An exception has occurred: %s\n",
96            e.getFullDescription().c_str());
97    return 1;
98#endif
99  }
100
101  return 0;
102}
103
Note: See TracBrowser for help on using the repository browser.