Changeset 2636 in orxonox.OLD for orxonox/trunk/src/orxonox.cc
- Timestamp:
- Oct 25, 2004, 12:48:39 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/orxonox.cc
r2551 r2636 29 29 #include "data_tank.h" 30 30 #include "command_node.h" 31 #include "game_loader.h" 31 32 #include <string.h> 32 33 … … 34 35 35 36 /** 36 37 \brief create a new Orxonox 37 38 */ 38 39 Orxonox::Orxonox () … … 42 43 43 44 /** 44 45 \brief remove Orxonox from memory 45 46 */ 46 47 Orxonox::~Orxonox () 47 48 { 48 49 50 51 52 49 Orxonox::singleton_ref = NULL; 50 if( world != NULL) delete world; 51 if( localinput != NULL) delete world; 52 if( localcamera != NULL) delete localcamera; 53 if( resources != NULL) delete resources; 53 54 } 54 55 … … 65 66 66 67 /** 67 68 69 70 71 68 \brief this finds the config file 69 70 Since the config file varies from user to user and since one may want to specify different config files 71 for certain occasions or platforms this function finds the right config file for every occasion and stores 72 it's path and name into configfilename 72 73 */ 73 74 void Orxonox::get_config_file (int argc, char** argv) 74 75 { 75 /* char* path;76 77 78 79 80 81 82 83 84 85 86 87 } 88 89 /** 90 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 87 strcpy (configfilename, "orxonox.conf"); 88 } 89 90 /** 91 \brief initialize Orxonox with command line 91 92 */ 92 93 int Orxonox::init (int argc, char** argv) 93 94 { 94 95 96 97 98 99 95 // parse command line 96 // config file 97 98 get_config_file (argc, argv); 99 100 // initialize SDL 100 101 printf("> Initializing SDL\n"); 101 102 if( SDL_Init (SDL_INIT_EVERYTHING) == -1) 102 {103 printf ("Could not SDL_Init(): %s\n", SDL_GetError());104 return -1;105 }106 107 103 { 104 printf ("Could not SDL_Init(): %s\n", SDL_GetError()); 105 return -1; 106 } 107 108 // initialize everything 108 109 printf("> Initializing video\n"); 109 110 if( init_video () == -1) return -1; 110 111 printf("> Initializing sound\n"); 111 112 if( init_sound () == -1) return -1; 112 113 printf("> Initializing input\n"); 113 114 if( init_input () == -1) return -1; 114 115 printf("> Initializing networking\n"); 115 116 if( init_networking () == -1) return -1; 116 117 printf("> Initializing resources\n"); 117 118 printf("> Initializing world\n");119 if( init_world () == -1) return -1; 120 121 122 } 123 124 /** 125 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 126 127 */ 127 128 int Orxonox::init_video () … … 161 162 162 163 // create camera 163 localcamera = new Camera( );164 165 return 0; 166 } 167 168 /** 169 164 localcamera = new Camera(world); 165 166 return 0; 167 } 168 169 /** 170 \brief initializes the sound engine 170 171 */ 171 172 int Orxonox::init_sound () 172 173 { 173 174 175 } 176 177 /** 178 174 printf("Not yet implemented\n"); 175 return 0; 176 } 177 178 /** 179 \brief initializes input functions 179 180 */ 180 181 int Orxonox::init_input () 181 182 { 182 183 184 185 186 } 187 188 /** 189 183 // create localinput 184 localinput = new CommandNode( configfilename); 185 186 return 0; 187 } 188 189 /** 190 \brief initializes network system 190 191 */ 191 192 int Orxonox::init_networking () 192 193 { 193 194 195 } 196 197 /** 198 194 printf("Not yet implemented\n"); 195 return 0; 196 } 197 198 /** 199 \brief initializes and loads resource files 199 200 */ 200 201 int Orxonox::init_resources () 201 202 { 202 203 204 } 205 206 /** 207 203 printf("Not yet implemented\n"); 204 return 0; 205 } 206 207 /** 208 \brief initializes the world 208 209 */ 209 210 int Orxonox::init_world () 210 211 { 211 world = new World(); 212 213 // TO DO: replace this with a menu/intro 214 world->load_debug_level(); 215 216 return 0; 217 } 218 219 /** 220 \brief exits Orxonox 212 //world = new World(); 213 214 // TO DO: replace this with a menu/intro 215 //world->load_debug_level(); 216 217 return 0; 218 } 219 220 221 /** 222 \brief starts the orxonox game or menu 223 224 here is the central orxonox state manager. There are currently two states 225 - menu 226 - game-play 227 both states manage their states themselfs again. 228 */ 229 void Orxonox::start() 230 { 231 232 this->gameLoader = GameLoader::getInstance(); 233 this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0); 234 this->gameLoader->init(); 235 this->gameLoader->start(); 236 } 237 238 /** 239 \brief exits Orxonox 221 240 */ 222 241 void Orxonox::quitGame() 223 242 { 224 225 } 226 227 /** 228 243 bQuitOrxonox = true; 244 } 245 246 /** 247 \brief this runs all of Orxonox 229 248 */ 230 249 void Orxonox::mainLoop() … … 236 255 while( !bQuitOrxonox) 237 256 { 238 printf("<==");239 240 257 // Network 241 258 synchronize(); … … 248 265 // Draw 249 266 display(); 250 251 printf(">\n");252 267 } 253 268 printf("Orxonox|Exiting the main loop\n"); … … 255 270 256 271 /** 257 258 272 \brief handles sprecial events from localinput 273 \param event: an event not handled by the CommandNode 259 274 */ 260 275 void Orxonox::event_handler (SDL_Event* event) 261 276 { 262 263 } 264 265 /** 266 277 // Handle special events such as reshape, quit, focus changes 278 } 279 280 /** 281 \brief synchronize local data with remote data 267 282 */ 268 283 void Orxonox::synchronize () 269 284 { 270 271 272 } 273 274 /** 275 285 // Get remote input 286 // Update synchronizables 287 } 288 289 /** 290 \brief run all input processing 276 291 */ 277 292 void Orxonox::handle_input () 278 293 { 279 280 281 282 } 283 284 /** 285 294 // localinput 295 localinput->process(); 296 // remoteinput 297 } 298 299 /** 300 \brief advance the timeline 286 301 */ 287 302 void Orxonox::time_slice () … … 295 310 { 296 311 float fps = 1000/dt; 297 printf(" %f", fps);312 printf("fps = %f\n", fps); 298 313 } 299 314 … … 306 321 307 322 /** 308 323 \brief compute collision detection 309 324 */ 310 325 void Orxonox::collision () 311 326 { 312 313 } 314 315 /** 316 317 318 327 world->collide (); 328 } 329 330 /** 331 \brief handle keyboard commands that are not meant for WorldEntities 332 \param cmd: the command to handle 333 \return true if the command was handled by the system or false if it may be passed to the WorldEntities 319 334 */ 320 335 bool Orxonox::system_command (Command* cmd) 321 336 { 322 323 324 if( !cmd->bUp) bQuitOrxonox = true;325 326 327 328 } 329 330 /** 331 337 if( !strcmp( cmd->cmd, "quit")) 338 { 339 if( !cmd->bUp) this->gameLoader->stop(); 340 return true; 341 } 342 return false; 343 } 344 345 /** 346 \brief render the current frame 332 347 */ 333 348 void Orxonox::display () 334 349 { 335 336 337 338 339 340 341 342 343 344 } 345 346 /** 347 348 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 } 360 361 /** 362 \brief retrieve a pointer to the local Camera 363 \return a pointer to localcamera 349 364 */ 350 365 Camera* Orxonox::get_camera () 351 366 { 352 353 } 354 355 /** 356 357 367 return localcamera; 368 } 369 370 /** 371 \brief retrieve a pointer to the local CommandNode 372 \return a pointer to localinput 358 373 */ 359 374 CommandNode* Orxonox::get_localinput () 360 375 { 361 362 } 363 364 /** 365 366 376 return localinput; 377 } 378 379 /** 380 \brief retrieve a pointer to the local World 381 \return a pointer to world 367 382 */ 368 383 World* Orxonox::get_world () 369 384 { 370 385 return world; 371 386 } 372 387 373 388 int main (int argc, char** argv) 374 389 { 375 390 printf(">>> Starting Orxonox <<<\n"); 376 391 Orxonox *orx = Orxonox::getInstance(); 377 392 378 393 if( (*orx).init(argc, argv) == -1) 379 { 380 printf("! Orxonox initialization failed\n"); 381 return -1; 382 } 383 384 (*orx).mainLoop(); 385 394 { 395 printf("! Orxonox initialization failed\n"); 396 return -1; 397 } 398 399 //(*orx).mainLoop(); 400 401 orx->start(); 402 386 403 //delete orx; 387 404
Note: See TracChangeset
for help on using the changeset viewer.