Changeset 2058 in orxonox.OLD for orxonox/branches/chris/src/orxonox.cc
- Timestamp:
- Jul 2, 2004, 11:36:56 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/orxonox.cc
r1982 r2058 24 24 */ 25 25 26 /* class definition header */ 26 #include <iostream> 27 #include <cstdio> 28 #include <GL/glut.h> 29 #include <SDL/SDL.h> 30 31 #include "environment.h" 32 #include "world.h" 33 #include "input_output.h" 34 #include "data_tank.h" 35 #include "stdincl.h" 36 #include "player.h" 37 #include "npc.h" 38 #include "shoot_laser.h" 39 27 40 #include "orxonox.h" 28 41 29 30 42 using namespace std; 31 43 32 44 33 34 45 Orxonox::Orxonox () 35 46 { … … 40 51 41 52 Orxonox::~Orxonox () 42 { 43 glutSetKeyRepeat(GLUT_KEY_REPEAT_ON); 44 } 53 {} 45 54 46 55 … … 63 72 //int Orxonox::offsetY = 0; 64 73 74 65 75 Orxonox* Orxonox::getInstance (void) 66 76 { … … 73 83 int Orxonox::globalInit (int argc, char** argv) 74 84 { 75 glutInit(&argc, argv); 76 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 85 if( SDL_Init (SDL_INIT_EVERYTHING) == -1) 86 { 87 printf ("Could not SDL_Init(): %s\n", SDL_GetError()); 88 return -1; 89 } 90 91 // Set video mode 92 // TO DO: parse arguments for settings 93 SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5); 94 SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5); 95 SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5); 96 SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16); 97 98 int bpp = 16; 99 int width = 640; 100 int height = 480; 101 Uint32 flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER; 102 103 if( (screen = SDL_SetVideoMode (width, height, bpp, flags)) == NULL) 104 { 105 printf ("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", width, height, bpp, flags, SDL_GetError()); 106 SDL_Quit(); 107 return -1; 108 } 109 110 // Set window labeling 111 // TO DO: Add version information to caption 112 SDL_WM_SetCaption( "Orxonox", "Orxonox"); 113 114 // TO DO: Create a cool icon and use it here 115 // SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); 116 117 // OpenGL stuff 118 // (Is this all we initialize globally???) 77 119 glEnable(GL_DEPTH_TEST); 78 glutInitWindowSize(500, 500);79 //glutFullScreen();80 glutInitWindowPosition(100, 100);81 glutCreateWindow("orxOnox");82 120 glShadeModel(GL_FLAT); 83 /* window event dispatchers */ 84 glutDisplayFunc(display); 85 glutReshapeFunc(reshape); 86 glutKeyboardFunc(keyboard); 87 glutKeyboardUpFunc(upKeyboard); 88 89 glutTimerFunc(1000, timeSlice, 0); 90 cout << "measuring performance..."; 121 122 // glutInit(&argc, argv); 123 // glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 124 // glutInitWindowSize(500, 500); 125 // //glutFullScreen(); 126 // glutInitWindowPosition(100, 100); 127 // glutCreateWindow("OrxonoX"); 128 // /* window event dispatchers */ 129 // glutDisplayFunc(display); 130 // glutReshapeFunc(reshape); 131 // glutKeyboardFunc(keyboard); 132 // glutKeyboardUpFunc(upKeyboard); 133 // 134 // glutTimerFunc(1000, timeSlice, 0); 135 // cout << "measuring performance..."; 136 91 137 } 92 138 … … 138 184 io->setPlayerStep(19.2/fps); /* set player to propper speed */ 139 185 localPlayer->shootLaser->setShootStep(20.0/fps); /* set shoot speed */ 140 localPlayer->shootRocket->setShootStep(20.0/fps); /* set shoot speed */141 186 world->setWorldStep(7.0/fps); /* set the speed of the terrain moving away */ 142 187 fps = 0; … … 261 306 (*world).drawWorld(); 262 307 263 glutSwapBuffers();264 } 308 SDL_Flip( screen); 309 } 265 310 266 311 … … 320 365 } 321 366 367 void Orxonox::mainLoop() 368 { 369 // This is where everything is run 370 while( !bQuitOrxonox) 371 { 372 // Process input 373 // Process time 374 // Process collision 375 // Draw 376 display(); 377 } 378 } 322 379 323 380 int main (int argc, char** argv) 324 381 { 325 382 Orxonox *orx = Orxonox::getInstance(); 326 (*orx).globalInit(argc, argv); 383 if( (*orx).globalInit(argc, argv) == -1) 384 { 385 printf("! Global initialization failed\n"); 386 return -1; 387 } 388 327 389 //(*orx).menuInit(); pb: directly jump to the game, no menu 328 (*orx).gameInit(); 329 330 glutMainLoop(); 390 391 if( (*orx).gameInit() == -1) 392 { 393 printf("! Game initialization failed\n"); 394 return -1; 395 } 396 397 (*orx).mainLoop(); 398 331 399 return 0; 332 400 } 401
Note: See TracChangeset
for help on using the changeset viewer.