Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3238 in orxonox.OLD for orxonox/branches/nico/src/orxonox.cc


Ignore:
Timestamp:
Dec 20, 2004, 2:42:54 AM (21 years ago)
Author:
bensch
Message:

orxonox/branches: updated branches: buerli, nico, sound. And moved bezierTrack to old.bezierTrack. Conflicts resolved in a usefull order.
Conflics mostly resolved in favor of trunk
merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/nico/src/orxonox.cc

    r2817 r3238  
    4747Orxonox::~Orxonox ()
    4848{
    49   Orxonox::singleton_ref = NULL;
     49  Orxonox::singletonRef = NULL;
    5050  if( world != NULL) delete world;
    5151  if( localinput != NULL) delete world;
     
    5656
    5757/* this is a singleton class to prevent duplicates */
    58 Orxonox* Orxonox::singleton_ref = 0;
     58Orxonox* Orxonox::singletonRef = 0;
    5959
    6060Orxonox* Orxonox::getInstance (void)
    6161{
    62   if (singleton_ref == NULL)
    63     singleton_ref = new Orxonox();
    64   return singleton_ref;
     62  if (singletonRef == NULL)
     63    singletonRef = new Orxonox();
     64  return singletonRef;
    6565}
    6666
     
    7272   it's path and name into configfilename
    7373*/
    74 void Orxonox::get_config_file (int argc, char** argv)
    75 {
    76   /*    char* path;
    77     #ifdef __WIN32__
    78     path = getenv("");
    79     #else
    80     path = getenv("HOME");
    81     #endif
    82    
    83     if( path != NULL) strcpy (configfilename, path);
    84     else strcpy (configfilename, "./");
    85     strcat (configfilename, "/.orxonox.conf");*/
    86  
     74void Orxonox::getConfigFile (int argc, char** argv)
     75{
    8776  strcpy (configfilename, "orxonox.conf");
    8877}
     
    9685  // config file
    9786 
    98   get_config_file (argc, argv);
    99  
    100   // initialize SDL
    101   printf("> Initializing SDL\n");
    102   if( SDL_Init (SDL_INIT_EVERYTHING) == -1)
     87  getConfigFile (argc, argv);
     88  SDL_Init (SDL_INIT_TIMER);
     89  // initialize everything
     90  if( initVideo() == -1) return -1;
     91  if( initSound() == -1) return -1;
     92  printf("> Initializing input\n");
     93  if( initInput() == -1) return -1;
     94  printf("> Initializing networking\n");
     95  if( initNetworking () == -1) return -1;
     96  printf("> Initializing resources\n");
     97  if( initResources () == -1) return -1;
     98  //printf("> Initializing world\n");
     99  //if( init_world () == -1) return -1; PB: world will be initialized when started
     100 
     101  return 0;
     102}
     103
     104/**
     105   \brief initializes SDL and OpenGL
     106*/
     107int Orxonox::initVideo()
     108{
     109  printf("> Initializing video\n");
     110  if (SDL_Init(SDL_INIT_VIDEO) == -1)
    103111    {
    104       printf ("Could not SDL_Init(): %s\n", SDL_GetError());
     112      printf ("could not initialize SDL Video\n");
    105113      return -1;
    106114    }
    107  
    108   // initialize everything
    109   printf("> Initializing video\n");
    110   if( init_video () == -1) return -1;
    111   printf("> Initializing sound\n");
    112   if( init_sound () == -1) return -1;
    113   printf("> Initializing input\n");
    114   if( init_input () == -1) return -1;
    115   printf("> Initializing networking\n");
    116   if( init_networking () == -1) return -1;
    117   printf("> Initializing resources\n");
    118   if( init_resources () == -1) return -1;
    119   //printf("> Initializing world\n");
    120   //if( init_world () == -1) return -1; PB: world will be initialized when started
    121  
    122   return 0;
    123 }
    124 
    125 /**
    126    \brief initializes SDL and OpenGL
    127 */
    128 int Orxonox::init_video ()
    129 {
    130115  // Set video mode
    131116  // TO DO: parse arguments for settings
    132   SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5);
    133   SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5);
    134   SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
    135   SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
     117  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
     118  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
     119  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
     120  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    136121 
    137122  int bpp = 16;
     
    140125  Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
    141126 
    142   if( (screen = SDL_SetVideoMode (width, height, bpp, flags)) == NULL)
     127  if((screen = SDL_SetVideoMode (width, height, bpp, flags)) == NULL)
    143128  {
    144     printf ("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", width, height, bpp, flags, SDL_GetError());
     129    printf("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", width, height, bpp, flags, SDL_GetError());
    145130    SDL_Quit();
    146131    return -1;
     
    148133 
    149134  // Set window labeling
    150   // TO DO: Add version information to caption
    151   SDL_WM_SetCaption( "Orxonox", "Orxonox");
     135  SDL_WM_SetCaption("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION);
    152136 
    153137  // TO DO: Create a cool icon and use it here
     
    176160 
    177161  // create camera
    178   localcamera = new Camera(world);
    179  
    180   return 0;
    181 }
     162  //localcamera = new Camera(world); /* \todo camera/input node not used anymore*/
     163 
     164  return 0;
     165}
     166
    182167
    183168/**
    184169   \brief initializes the sound engine
    185170*/
    186 int Orxonox::init_sound ()
    187 {
     171int Orxonox::initSound()
     172{
     173  printf("> Initializing sound\n");
     174  // SDL_Init(SDL_INIT_AUDIO);
    188175  printf("Not yet implemented\n");
    189176  return 0;
    190177}
    191178
     179
    192180/**
    193181   \brief initializes input functions
    194182*/
    195 int Orxonox::init_input ()
     183int Orxonox::initInput()
    196184{
    197185  // create localinput
     
    201189}
    202190
     191
    203192/**
    204193   \brief initializes network system
    205194*/
    206 int Orxonox::init_networking ()
     195int Orxonox::initNetworking()
    207196{
    208197  printf("Not yet implemented\n");
     
    210199}
    211200
     201
    212202/**
    213203   \brief initializes and loads resource files
    214204*/
    215 int Orxonox::init_resources ()
     205int Orxonox::initResources()
    216206{
    217207  printf("Not yet implemented\n");
     
    219209}
    220210
     211
    221212/**
    222213   \brief initializes the world
    223214*/
    224 int Orxonox::init_world ()
     215int Orxonox::initWorld()
    225216{
    226217  //world = new World();
     
    250241}
    251242
     243
    252244/**
    253245   \brief exits Orxonox
     
    258250}
    259251
    260 /**
    261    \brief this runs all of Orxonox
    262 */
    263 void Orxonox::mainLoop()
    264 {
    265   lastframe = SDL_GetTicks();
    266   bQuitOrxonox = false;
    267   // This is where everything is run
    268   printf("Orxonox|Entering main loop\n");
    269   while( !bQuitOrxonox)
    270     {
    271       // Network
    272       synchronize();
    273       // Process input
    274       handle_input();
    275       // Process time
    276       time_slice();
    277       // Process collision
    278       collision();
    279       // Draw
    280       display();
    281     }
    282   printf("Orxonox|Exiting the main loop\n");
    283 }
     252
    284253
    285254/**
     
    287256   \param event: an event not handled by the CommandNode
    288257*/
    289 void Orxonox::event_handler (SDL_Event* event)
     258void Orxonox::eventHandler(SDL_Event* event)
    290259{
    291260  // Handle special events such as reshape, quit, focus changes
    292261}
    293 
    294 /**
    295    \brief synchronize local data with remote data
    296 */
    297 void Orxonox::synchronize ()
    298 {
    299   // Get remote input
    300   // Update synchronizables
    301 }
    302 
    303 /**
    304    \brief run all input processing
    305 */
    306 void Orxonox::handle_input ()
    307 {
    308   // localinput
    309   localinput->process();
    310   // remoteinput
    311 }
    312 
    313 /**
    314    \brief advance the timeline
    315 */
    316 void Orxonox::time_slice ()
    317 {
    318   Uint32 curframe = SDL_GetTicks();
    319   if( !pause)
    320     {
    321       Uint32 dt = curframe - lastframe;
    322      
    323       if(dt > 0)
    324         {
    325           float fps = 1000/dt;
    326           printf("fps = %f\n", fps);
    327         }
    328      
    329       world->time_slice (dt);
    330       world->update ();
    331       localcamera->time_slice (dt);
    332     }
    333   lastframe = curframe;
    334 }
    335 
    336 /**
    337    \brief compute collision detection
    338 */
    339 void Orxonox::collision ()
    340 {
    341   world->collide ();
    342 }
     262 
    343263
    344264/**
     
    347267   \return true if the command was handled by the system or false if it may be passed to the WorldEntities
    348268*/
    349 bool Orxonox::system_command (Command* cmd)
    350 {
     269bool Orxonox::systemCommand(Command* cmd)
     270{
     271  /*
    351272  if( !strcmp( cmd->cmd, "quit"))
    352273    {
     
    355276    }
    356277  return false;
    357 }
    358 
    359 /**
    360    \brief render the current frame
    361 */
    362 void Orxonox::display ()
    363 {
    364   // clear buffer
    365   glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    366   // set camera
    367   localcamera->apply ();
    368   // draw world
    369   world->draw ();
    370   // draw HUD
    371   // flip buffers
    372   SDL_GL_SwapBuffers();
    373 }
     278  */
     279  return false;
     280}
     281
    374282
    375283/**
     
    377285   \return a pointer to localcamera
    378286*/
    379 Camera* Orxonox::get_camera ()
     287Camera* Orxonox::getCamera()
    380288{
    381289  return localcamera;
    382290}
     291
    383292
    384293/**
     
    386295   \return a pointer to localinput
    387296*/
    388 CommandNode* Orxonox::get_localinput ()
     297CommandNode* Orxonox::getLocalInput()
    389298{
    390299  return localinput;
    391300}
     301
    392302
    393303/**
     
    395305   \return a pointer to world
    396306*/
    397 World* Orxonox::get_world ()
     307World* Orxonox::getWorld()
    398308{
    399309  return world;
    400310}
    401311
    402 int main (int argc, char** argv)
     312
     313
     314
     315int main(int argc, char** argv)
    403316
    404317  printf(">>> Starting Orxonox <<<\n");
    405318  Orxonox *orx = Orxonox::getInstance();
    406319 
    407   if( (*orx).init(argc, argv) == -1)
     320  if((*orx).init(argc, argv) == -1)
    408321    {
    409322      printf("! Orxonox initialization failed\n");
     
    411324    }
    412325 
    413   //(*orx).mainLoop();
    414 
    415326  orx->start();
    416327 
Note: See TracChangeset for help on using the changeset viewer.