Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 27, 2008, 5:15:08 PM (16 years ago)
Author:
rgrieder
Message:
  • added debug output to the InputHandler
  • fixed singleton issues
  • cleaned up Main.cc (replaced WinMain by main)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/orxonox/Main.cc

    r918 r934  
    2727
    2828 /**
    29  @file  Main.cc
    30  @brief main file handling most of the machine specific code
     29 @file
     30 @brief Entry point of the program. Platform specific code.
    3131  */
    3232
    3333#include "OrxonoxStableHeaders.h"
    3434
    35 #include <OgrePlatform.h>
    36 #include <OgreException.h>
     35#include <exception>
    3736
    38 
     37#include "OrxonoxPlatform.h"
    3938#include "core/SignalHandler.h"
    4039#include "Orxonox.h"
    4140
    4241using namespace orxonox;
    43 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
     42#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
    4443#include <CoreFoundation/CoreFoundation.h>
    4544
     
    7271#endif
    7372
    74 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 && !defined( __MINGW32__ )
    75 #ifndef WIN32_LEAN_AND_MEAN
    76 #define WIN32_LEAN_AND_MEAN
    77 #endif
    78 #include <windows.h>
    79   INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
    80   {
    81     // something like this would be less hacky
    82     // maybe one can work with trailing '\0'
    83     // or maybe use string based functions
    84     // I was unable to test it without working windows version
    85     char* cmd = strCmdLine;
    86     int argc = 2;
    87     int i;
    88     int j;
    89     for(i = 0; cmd[i] != NULL; i++)
    90     {
    91       if(cmd[i] == ' ') argc++;
    92     }
    93     char **argv = new char*[argc];
    94     for (j = 0; j < argc; j++)
    95     {
    96       argv[j] = new char[i];
    97     }
    98     j = 1;
    99     int k = 0;
    100     for(int i = 0; cmd[i] != NULL; i++)
    101     {
    102       if(cmd[i] != ' ') {
    103         argv[j][k] = cmd[i];
    104         k++;
    105       }
    106       else {
    107         argv[j][k] = '\0';
    108         k = 0;
    109         j++;
    110       }
    111     }
    112     argv[j][k] = '\0';
    113     argv[0] = "BeniXonox.exe";
    114     //char *argv[2];
    115     //argv[0] = "asdfProgram";
    116     //argv[1] =  strCmdLine;
    117     //int argc = 2;
     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());
    11881#else
    119   int main(int argc, char **argv)
    120   {
    121 #endif
    122     try {
    123       srand(time(0));  //initaialize RNG; TODO check if it works on win
    124       SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
    125       Orxonox* orx = Orxonox::getSingleton();
    126 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    127       orx->init(argc, argv, macBundlePath());
    128       orx->start();
    129 #else
    130 /*
    131 for (int i = 0; i < 500; i++)
    132 {
    133 int x = rand() % 40000 - 20000;
    134 int y = rand() % 40000 - 20000;
    135 int z = rand() % 40000 - 20000;
    136 
    137 int scale = rand() % 100 + 20;
    138 
    139 int version = rand() % 6 + 1;
    140 
    141 float rotx = float(rand()) / RAND_MAX;
    142 float roty = float(rand()) / RAND_MAX;
    143 float rotz = float(rand()) / RAND_MAX;
    144 
    145 int axis = rand() % 3 + 1;
    146 
    147 if (axis == 1)
    148   rotx = 0;
    149 if (axis == 2)
    150   roty = 0;
    151 if (axis == 3)
    152   rotz = 0;
    153 
    154 int rotation = rand() % 40 + 10;
    155 
    156 //    <Model position="1000,1500,0" scale="50" mesh="ast1.mesh" rotationAxis="0,1.25,0" rotationRate="70" />
    157 std::cout << "    <Model position=\"" << x << "," << y << "," << z << "\" scale=\"" << scale << "\" mesh=\"ast" << version << ".mesh\" rotationAxis=\"" << rotx << "," << roty << "," << rotz << "\" rotationRate=\"" << rotation << "\" />" << std::endl;
    158 
    159 
    160 }
    161 */
    162       orx->init(argc, argv, "");
    163       orx->start();
    164 #endif
    165     }
    166     catch (Ogre::Exception& e) {
    167 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 && !defined( __MINGW32__ )
    168       MessageBoxA(NULL, e.getFullDescription().c_str(),
    169             "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
    170 #else
    171       std::cerr << "Exception:\n";
    172       std::cerr << e.getFullDescription().c_str() << "\n";
    173 #endif
    174       return 1;
    175     }
    176     return 0;
    177   }
    178 
    179 #ifdef __cplusplus
    180 }
     82    orx->init(argc, argv, "");
    18183#endif
    18284
    183 
    184 /*int main(int argc, char **argv)
    185 {
    186   try
     85    orx->start();
     86    orx->destroy();
     87  }
     88  catch (std::exception &ex)
    18789  {
    188     SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
    189     Orxonox* orx = Orxonox::getSingleton();
    190 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    191     orx->init(argc, argv, macBundlePath());
    192     orx->start();
    193 #else
    194     orx->init(argc, argv, "");
    195     orx->start();
    196 #endif
    197 
    198   }
    199   catch(Ogre::Exception& e)
    200   {
    201     fprintf(stderr, "An exception has occurred: %s\n",
    202             e.getFullDescription().c_str());
     90    std::cerr << "Exception:\n";
     91    std::cerr << ex.what() << "\n";
    20392    return 1;
    20493  }
     
    20796}
    20897
    209 */
     98#ifdef __cplusplus
     99}
     100#endif
Note: See TracChangeset for help on using the changeset viewer.