Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2058 in orxonox.OLD for orxonox/branches/chris/src/orxonox.cc


Ignore:
Timestamp:
Jul 2, 2004, 11:36:56 AM (21 years ago)
Author:
chris
Message:

orxonox/branches/chris: Trunk remerged into my branch started on SDL reconfiguration

File:
1 edited

Legend:

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

    r1982 r2058  
    2424*/
    2525
    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
    2740#include "orxonox.h"
    2841
    29 
    3042using namespace std;
    3143
    3244
    33 
    3445Orxonox::Orxonox ()
    3546{
     
    4051
    4152Orxonox::~Orxonox ()
    42 {
    43   glutSetKeyRepeat(GLUT_KEY_REPEAT_ON);
    44 }
     53{}
    4554
    4655
     
    6372//int Orxonox::offsetY = 0;
    6473
     74
    6575Orxonox* Orxonox::getInstance (void)
    6676{
     
    7383int Orxonox::globalInit (int argc, char** argv)
    7484{
    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???)
    77119  glEnable(GL_DEPTH_TEST);
    78   glutInitWindowSize(500, 500);
    79   //glutFullScreen();
    80   glutInitWindowPosition(100, 100);
    81   glutCreateWindow("orxOnox");
    82120  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
    91137}
    92138
     
    138184  io->setPlayerStep(19.2/fps); /* set player to propper speed */
    139185  localPlayer->shootLaser->setShootStep(20.0/fps); /* set shoot speed */
    140   localPlayer->shootRocket->setShootStep(20.0/fps); /* set shoot speed */
    141186  world->setWorldStep(7.0/fps); /* set the speed of the terrain moving away */
    142187  fps = 0;
     
    261306  (*world).drawWorld();
    262307
    263   glutSwapBuffers();
    264 } 
     308  SDL_Flip( screen);
     309}
    265310
    266311
     
    320365}
    321366
     367void 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}
    322379
    323380int main (int argc, char** argv)
    324381
    325382  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 
    327389  //(*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 
    331399  return 0;
    332400}
     401
Note: See TracChangeset for help on using the changeset viewer.