Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2105 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Jul 11, 2004, 3:14:52 PM (20 years ago)
Author:
chris
Message:

orxonox/branches/chris: Port to SDL complete. Everything compiles and the generated executable runs without crashing. Keyboard and mouse handling works. Drawing is messed up, possibly because of my incompetent Rotation class. Hence all you see at them moment is a pitch black screen. I added the makefile I used to compile it since bensch hasn't yet included SDL into the configure script.

Location:
orxonox/branches/chris/src
Files:
2 added
6 edited

Legend:

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

    r2100 r2105  
    2222#include <stdio.h>
    2323#include <strings.h>
     24#include <stdlib.h>
    2425
    2526using namespace std;
     
    5253        FILE* stream;
    5354       
     55        printf("Loading key bindings from %s\n", filename);
     56       
    5457        if( filename == NULL) filename = DEFAULT_KEYBIND_FILE;
    5558       
     
    7376        char namebuf[256];
    7477        char valuebuf[256];
     78        memset (namebuf, 0, 256);
     79        memset (valuebuf, 0, 256);
    7580        int* index;
    7681
     
    8186                {
    8287                        case 0:
     88                                printf("Key binding %d(%s) set to %s\n", index[1], SDLK_to_keyname( index[1]), valuebuf);
    8389                                strcpy (aliases->keys[index[1]], valuebuf);
    8490                                break;
    8591                        case 1:
     92                                printf("Button binding %d(%s) set to %s\n", index[1], SDLB_to_buttonname( index[1]), valuebuf);
    8693                                strcpy (aliases->buttons[index[1]], valuebuf);
    8794                                break;
     
    8996                                break;
    9097                }
     98                memset (namebuf, 0, 256);
     99                memset (valuebuf, 0, 256);
    91100        }
    92101}
     
    105114{
    106115        coord[0] = -1;
    107         if( (coord[1] = keyname_to_SDLK (name)) != -1) coord[0] = 0;
    108         if( (coord[1] = buttonname_to_SDLB (name)) != -1) coord[0] = 1;
     116        coord[1] = -1;
     117        int c;
     118        if( (c = keyname_to_SDLK (name)) != -1)
     119        {
     120                coord[1] = c;
     121                coord[0] = 0;
     122        }
     123        if( (c = buttonname_to_SDLB (name)) != -1)
     124        {
     125                coord[1] = c;
     126                coord[0] = 1;
     127        }
    109128        return coord;
    110129}
     
    112131void CommandNode::process ()
    113132{
     133perror("CommandNode|process()");
    114134        if( bLocalInput) process_local ();
    115135        else process_network ();
     
    123143        while( SDL_PollEvent (&event))
    124144        {
     145                memset (cmd.cmd, 0, CMD_LENGHT);
    125146                switch( event.type)
    126147                {
     
    173194void CommandNode::relay (Command* cmd)
    174195{
     196perror("CommandNode|relay()");
    175197        List<WorldEntity>* plist = bound;
    176198       
     199        Orxonox *orx = Orxonox::getInstance();
     200        if( orx->system_command (cmd)) return;
     201               
    177202        if( bLocalInput) send_over_network (cmd);
    178203       
  • orxonox/branches/chris/src/command_node.h

    r2100 r2105  
    4242        KeyBindings* aliases;
    4343        List<WorldEntity>* bound;       //!< List of WorldEntites that recieve commands from this CommandNode
    44         int coord[2];
     44        Sint32 coord[2];
    4545       
    4646        void relay (Command* cmd);
  • orxonox/branches/chris/src/keynames.cc

    r2100 r2105  
    4848        if( !strcmp (name, "RETURN")) return SDLK_RETURN;
    4949        if( !strcmp (name, "ESCAPE")) return SDLK_ESCAPE;
     50        if( !strcmp (name, "SPACE")) return SDLK_SPACE;
    5051        if( !strcmp (name, "EXCLAIM")) return SDLK_EXCLAIM;
    5152        if( !strcmp (name, "QUOTEDBL")) return SDLK_QUOTEDBL;
     
    184185        if( key == SDLK_CLEAR) return "CLEAR";
    185186        if( key == SDLK_RETURN) return "RETURN";
     187        if( key == SDLK_SPACE) return "SPACE";
    186188        if( key == SDLK_ESCAPE) return "ESCAPE";
    187189        if( key == SDLK_EXCLAIM) return "EXCLAIM";
  • orxonox/branches/chris/src/orxonox.cc

    r2104 r2105  
    7272        strcat (configfilename, "/.orxonox.conf");*/
    7373       
    74         strcpy (configfilename, "./orxonox.conf");
     74        strcpy (configfilename, "orxonox.conf");
    7575}
    7676
     
    119119  int width = 640;
    120120  int height = 480;
    121   Uint32 flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
     121  Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
    122122 
    123123  if( (screen = SDL_SetVideoMode (width, height, bpp, flags)) == NULL)
     
    187187{
    188188        bQuitOrxonox = true;
    189   //cout << "finished garbage colletion, quitting..." << endl;
    190189}
    191190void Orxonox::mainLoop()
    192191{
    193192        lastframe = SDL_GetTicks();
    194 
     193        bQuitOrxonox = false;
    195194  // This is where everything is run
     195printf("Orxonox|Entering main loop\n");
    196196  while( !bQuitOrxonox)
    197197  {
     
    207207    display();
    208208  }
     209printf("Orxonox|Exiting the main loop\n");
    209210}
    210211
     
    244245}
    245246
     247bool Orxonox::system_command (Command* cmd)
     248{
     249        if( !strcmp( cmd->cmd, "quit") && !cmd->bUp)
     250        {
     251                bQuitOrxonox = true;
     252                return true;
     253        }
     254}
     255
    246256void Orxonox::display ()
    247257{
     
    254264                // draw HUD
    255265                // flip buffers
    256         SDL_Flip( screen);
     266        SDL_GL_SwapBuffers();
    257267}
    258268
     
    274284int main (int argc, char** argv)
    275285
     286        printf(">>> Starting Orxonox <<<\n");
    276287  Orxonox *orx = Orxonox::getInstance();
    277288 
  • orxonox/branches/chris/src/orxonox.h

    r2104 r2105  
    5353
    5454  void event_handler (SDL_Event* event);
     55  bool system_command (Command* cmd);
    5556
    5657  int init (int argc, char** argv);
  • orxonox/branches/chris/src/player.cc

    r2101 r2105  
    6161void Player::command (Command* cmd)
    6262{
    63         if( strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;
    64         else if( strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;
    65         else if( strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;
    66         else if( strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;
    67         else if( strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;
     63        if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;
     64        else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;
     65        else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;
     66        else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;
     67        else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;
    6868}
    6969
    7070void Player::draw ()
    7171{
     72        glMatrixMode(GL_MODELVIEW);
     73        float matrix[16];
     74  get_placement()->w.glmatrix (matrix);
     75  glLoadMatrixf (matrix);
     76
     77        glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z);
     78       
     79        glBegin(GL_TRIANGLES);
     80        glColor3f(1,0,0);
     81        glVertex3f(0,0,0);
     82        glColor3f(0,1,0);
     83        glVertex3f(-1,-0.5,0);
     84        glColor3f(0,0,1);
     85        glVertex3f(-1,+0.5,0);
     86        glEnd();
    7287}
    7388
Note: See TracChangeset for help on using the changeset viewer.