Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3238 in orxonox.OLD for orxonox/branches/sound/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/sound/src/orxonox.cc

    r2636 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
     
    158142  glClearColor(0.0, 0.0, 0.0, 0.0);
    159143  glEnable(GL_DEPTH_TEST);
    160   glEnable(GL_COLOR);
    161   glShadeModel(GL_FLAT);
     144 
     145  // LIGHTING
     146  GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
     147  GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0};
     148  GLfloat lightPosition[] = {10.0, 10, 19.0, 0.0};
     149
     150  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
     151  glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight);
     152  glEnable(GL_LIGHTING);
     153  glEnable(GL_LIGHT0);
     154  glEnable(GL_DEPTH_TEST);
     155  glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
     156  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
     157   
     158  //  glEnable(GL_COLOR);
     159  //  glShadeModel(GL_SMOOTH);
    162160 
    163161  // create camera
    164   localcamera = new Camera(world);
    165  
    166   return 0;
    167 }
     162  //localcamera = new Camera(world); /* \todo camera/input node not used anymore*/
     163 
     164  return 0;
     165}
     166
    168167
    169168/**
    170169   \brief initializes the sound engine
    171170*/
    172 int Orxonox::init_sound ()
    173 {
     171int Orxonox::initSound()
     172{
     173  printf("> Initializing sound\n");
     174  // SDL_Init(SDL_INIT_AUDIO);
    174175  printf("Not yet implemented\n");
    175176  return 0;
    176177}
    177178
     179
    178180/**
    179181   \brief initializes input functions
    180182*/
    181 int Orxonox::init_input ()
     183int Orxonox::initInput()
    182184{
    183185  // create localinput
     
    187189}
    188190
     191
    189192/**
    190193   \brief initializes network system
    191194*/
    192 int Orxonox::init_networking ()
     195int Orxonox::initNetworking()
    193196{
    194197  printf("Not yet implemented\n");
     
    196199}
    197200
     201
    198202/**
    199203   \brief initializes and loads resource files
    200204*/
    201 int Orxonox::init_resources ()
     205int Orxonox::initResources()
    202206{
    203207  printf("Not yet implemented\n");
     
    205209}
    206210
     211
    207212/**
    208213   \brief initializes the world
    209214*/
    210 int Orxonox::init_world ()
     215int Orxonox::initWorld()
    211216{
    212217  //world = new World();
     
    236241}
    237242
     243
    238244/**
    239245   \brief exits Orxonox
     
    244250}
    245251
    246 /**
    247    \brief this runs all of Orxonox
    248 */
    249 void Orxonox::mainLoop()
    250 {
    251   lastframe = SDL_GetTicks();
    252   bQuitOrxonox = false;
    253   // This is where everything is run
    254   printf("Orxonox|Entering main loop\n");
    255   while( !bQuitOrxonox)
    256     {
    257       // Network
    258       synchronize();
    259       // Process input
    260       handle_input();
    261       // Process time
    262       time_slice();
    263       // Process collision
    264       collision();
    265       // Draw
    266       display();
    267     }
    268   printf("Orxonox|Exiting the main loop\n");
    269 }
     252
    270253
    271254/**
     
    273256   \param event: an event not handled by the CommandNode
    274257*/
    275 void Orxonox::event_handler (SDL_Event* event)
     258void Orxonox::eventHandler(SDL_Event* event)
    276259{
    277260  // Handle special events such as reshape, quit, focus changes
    278261}
    279 
    280 /**
    281    \brief synchronize local data with remote data
    282 */
    283 void Orxonox::synchronize ()
    284 {
    285   // Get remote input
    286   // Update synchronizables
    287 }
    288 
    289 /**
    290    \brief run all input processing
    291 */
    292 void Orxonox::handle_input ()
    293 {
    294   // localinput
    295   localinput->process();
    296   // remoteinput
    297 }
    298 
    299 /**
    300    \brief advance the timeline
    301 */
    302 void Orxonox::time_slice ()
    303 {
    304   Uint32 curframe = SDL_GetTicks();
    305   if( !pause)
    306     {
    307       Uint32 dt = curframe - lastframe;
    308      
    309       if(dt > 0)
    310         {
    311           float fps = 1000/dt;
    312           printf("fps = %f\n", fps);
    313         }
    314      
    315       world->time_slice (dt);
    316       world->update ();
    317       localcamera->time_slice (dt);
    318     }
    319   lastframe = curframe;
    320 }
    321 
    322 /**
    323    \brief compute collision detection
    324 */
    325 void Orxonox::collision ()
    326 {
    327   world->collide ();
    328 }
     262 
    329263
    330264/**
     
    333267   \return true if the command was handled by the system or false if it may be passed to the WorldEntities
    334268*/
    335 bool Orxonox::system_command (Command* cmd)
    336 {
     269bool Orxonox::systemCommand(Command* cmd)
     270{
     271  /*
    337272  if( !strcmp( cmd->cmd, "quit"))
    338273    {
     
    341276    }
    342277  return false;
    343 }
    344 
    345 /**
    346    \brief render the current frame
    347 */
    348 void Orxonox::display ()
    349 {
    350   // clear buffer
    351   glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    352   // set camera
    353   localcamera->apply ();
    354   // draw world
    355   world->draw ();
    356   // draw HUD
    357   // flip buffers
    358   SDL_GL_SwapBuffers();
    359 }
     278  */
     279  return false;
     280}
     281
    360282
    361283/**
     
    363285   \return a pointer to localcamera
    364286*/
    365 Camera* Orxonox::get_camera ()
     287Camera* Orxonox::getCamera()
    366288{
    367289  return localcamera;
    368290}
     291
    369292
    370293/**
     
    372295   \return a pointer to localinput
    373296*/
    374 CommandNode* Orxonox::get_localinput ()
     297CommandNode* Orxonox::getLocalInput()
    375298{
    376299  return localinput;
    377300}
     301
    378302
    379303/**
     
    381305   \return a pointer to world
    382306*/
    383 World* Orxonox::get_world ()
     307World* Orxonox::getWorld()
    384308{
    385309  return world;
    386310}
    387311
    388 int main (int argc, char** argv)
     312
     313
     314
     315int main(int argc, char** argv)
    389316
    390317  printf(">>> Starting Orxonox <<<\n");
    391318  Orxonox *orx = Orxonox::getInstance();
    392319 
    393   if( (*orx).init(argc, argv) == -1)
     320  if((*orx).init(argc, argv) == -1)
    394321    {
    395322      printf("! Orxonox initialization failed\n");
     
    397324    }
    398325 
    399   //(*orx).mainLoop();
    400 
    401326  orx->start();
    402327 
Note: See TracChangeset for help on using the changeset viewer.