Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 544 was 544, checked in by rgrieder, 16 years ago
  • added WinMain (no argument parser yet)
  • made a few more adjustments, so that it compiles now under VC8 (actually it doesn't, I need to comment the with getMouseState or else I get a very strange linker error) (but I haven't committed this of course, since it compiles on tardis boxes)
File size: 3.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  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 "core/SignalHandler.h"
38#include "orxonox.h"
39
40using namespace orxonox;
41using namespace Ogre;
42#if OGRE_PLATFORM == OGRE_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
73#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
74#define WIN32_LEAN_AND_MEAN
75#include "windows.h"
76  INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
77  {
78    char *argv[2];
79    argv[0] = "asdfprogramName";
80    argv[1] =  strCmdLine;
81    int argc = 2;
82#else
83  int main(int argc, char **argv) 
84  {
85#endif
86    try {
87      SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
88      Orxonox* orx = Orxonox::getSingleton();
89#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
90      orx->init(argc, argv, macBundlePath());
91      orx->start();
92#else
93      orx->init(argc, argv, "");
94      orx->start();
95#endif
96    }
97    catch (Ogre::Exception& e) {
98#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
99      MessageBoxA(NULL, e.getFullDescription().c_str(),
100            "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
101#else
102      std::cerr << "Exception:\n";
103      std::cerr << e.getFullDescription().c_str() << "\n";
104#endif
105      return 1;
106    }
107    return 0;
108  }
109
110#ifdef __cplusplus
111}
112#endif
113
114
115/*int main(int argc, char **argv)
116{
117  try
118  {
119    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
120    Orxonox* orx = Orxonox::getSingleton();
121#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
122    orx->init(argc, argv, macBundlePath());
123    orx->start();
124#else
125    orx->init(argc, argv, "");
126    orx->start();
127#endif
128
129  }
130  catch(Ogre::Exception& e)
131  {
132    fprintf(stderr, "An exception has occurred: %s\n",
133            e.getFullDescription().c_str());
134    return 1;
135  }
136
137  return 0;
138}
139
140*/
Note: See TracBrowser for help on using the repository browser.