Back to index

extremetuxracer  0.5beta
Functions
winsys.h File Reference
#include "SDL.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void setup_sdl_video_mode ()
 Sets up the SDL OpenGL rendering context.
void winsys_post_redisplay ()
 Requests that the screen be redrawn.
void winsys_swap_buffers ()
 Copies the OpenGL back buffer to the front buffer.
void winsys_enable_key_repeat (bool enabled)
 Enables/disables key repeat messages from being generated.
void winsys_warp_pointer (int x, int y)
 Moves the mouse pointer to (x,y)
void winsys_show_cursor (bool visible)
 Shows/hides mouse cursor.
void winsys_init (int *argc, char **argv, char *window_title, char *icon_title)
 Initializes the OpenGL rendering context, and creates a window (or sets up fullscreen mode if selected)
void winsys_shutdown ()
 Deallocates resources in preparation for program termination.
void winsys_process_events ()
 Processes and dispatches events.
void winsys_exit (int code)

Function Documentation

Sets up the SDL OpenGL rendering context.

Author:
jfpatry
Date:
Created: 2000-10-20
Modified: 2000-10-20

Definition at line 89 of file winsys.cpp.

{
    Uint32 video_flags = SDL_OPENGL; 
    int bpp = 0;
    int width, height;

    if ( getparam_fullscreen() ) {
              video_flags |= SDL_FULLSCREEN;
    } else {
              video_flags |= SDL_RESIZABLE;
    }
       
#if SDL_VERSION_ATLEAST(1,2,6)
       if(getparam_enable_fsaa()){
              //enable FSAA
              SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1);
              SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, getparam_multisamples());
       }
#endif
       
       if(getparam_stencil_buffer()){
              SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
       }

    switch ( getparam_bpp_mode() ) {
    case 0:
              /* Use current bpp */
              bpp = 0;
       break;

    case 1:
              /* 16 bpp */
              bpp = 16;
       break;

    case 2:
              /* 32 bpp */
              bpp = 32;
       break;

    default:
              setparam_bpp_mode( 0 );
              bpp = getparam_bpp_mode();
    }

    width = getparam_x_resolution();
       
       if(getparam_x_resolution_half_width()){
              width /=2;           
       }
       
    height = getparam_y_resolution();
    
    if(width < 800) width = 800;
    if(height < 600) height = 600;

    if ( ( screen = SDL_SetVideoMode( width, height, bpp, video_flags ) ) ==  NULL ){
       handle_system_error( 1, "Couldn't initialize video: %s", 
                          SDL_GetError() );
    }
       
       glViewport(0,0,width,height);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void winsys_enable_key_repeat ( bool  enabled)

Enables/disables key repeat messages from being generated.

Returns:
Author:
jfpatry
Date:
Created: 2000-10-19
Modified: 2000-10-19

Definition at line 208 of file winsys.cpp.

{
    if ( enabled ) {
       SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY,
                          SDL_DEFAULT_REPEAT_INTERVAL );
    } else {
       SDL_EnableKeyRepeat( 0, 0 );
    }
}

Here is the caller graph for this function:

void winsys_exit ( int  code)

Definition at line 329 of file winsys.cpp.

{
    players[0].saveData();
    Highscore->saveData();
    cleanup();
    
    exit( code );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void winsys_init ( int *  argc,
char **  argv,
char *  window_title,
char *  icon_title 
)

Initializes the OpenGL rendering context, and creates a window (or sets up fullscreen mode if selected)

Author:
jfpatry
Date:
Created: 2000-10-19
Modified: 2000-10-19

Definition at line 163 of file winsys.cpp.

{
    Uint32 sdl_flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;

    /*
     * Initialize SDL
     */
    if ( SDL_Init( sdl_flags ) < 0 ) {
       handle_error( 1, "Couldn't initialize SDL: %s", SDL_GetError() );
    }


    /* 
     * Init video 
     */
    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

    setup_sdl_video_mode();

    SDL_WM_SetCaption( window_title, icon_title );

}

Here is the call graph for this function:

Here is the caller graph for this function:

Requests that the screen be redrawn.

Author:
jfpatry
Date:
Created: 2000-10-19
Modified: 2000-10-19

Definition at line 50 of file winsys.cpp.

{
    redisplay = true;
}

Here is the caller graph for this function:

Processes and dispatches events.

This function never returns.

Returns:
No.
Author:
jfpatry
Date:
Created: 2000-10-19
Modified: 2000-10-19

Definition at line 239 of file winsys.cpp.

{
       SDL_Event event; 
    int x, y;

    while (true) {

       SDL_LockAudio();
       SDL_UnlockAudio();

       while ( SDL_PollEvent( &event ) ) {
           
           switch ( event.type ) {
           case SDL_KEYDOWN:
                  SDL_GetMouseState( &x, &y );
                     loop_keyboard_func( event.key.keysym.sym,
                                          event.key.keysym.mod,
                                   false,
                                   x, y );
                     break;

           case SDL_KEYUP:
                  SDL_GetMouseState( &x, &y );
                  loop_keyboard_func( event.key.keysym.sym,
                                   event.key.keysym.mod,
                                   true,
                                   x, y );
              break;

           case SDL_MOUSEBUTTONDOWN:
           case SDL_MOUSEBUTTONUP:
                     loop_mouse_func( event.button.button,
                               event.button.state,
                               event.button.x,
                               event.button.y );
              break;

           case SDL_MOUSEMOTION:
              if ( event.motion.state ) {
                  /* buttons are down */
                     loop_mouse_motion_func( event.motion.x,
                                   event.motion.y );
              } else {
                  /* no buttons are down */
                     loop_mouse_motion_func( event.motion.x,
                                          event.motion.y );
              }
              break;

           case SDL_VIDEORESIZE:
              setup_sdl_video_mode();
                  reshape( event.resize.w,
                                 event.resize.h );
              break;
                     
              case SDL_QUIT:
                     winsys_exit(0);             
                     break;
              
           }

           SDL_LockAudio();
           SDL_UnlockAudio();
       }

       if ( redisplay ) {
           redisplay = false;
       }
       main_loop();

       /* Delay for 1 ms.  This allows the other threads to do some
          work (otherwise the audio thread gets starved). */
       SDL_Delay(1);

    }

    /* Never exits */
    code_not_reached();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void winsys_show_cursor ( bool  visible)

Shows/hides mouse cursor.

Author:
jfpatry
Date:
Created: 2000-10-19
Modified: 2000-10-19

Definition at line 226 of file winsys.cpp.

{
    SDL_ShowCursor( visible );
}

Here is the caller graph for this function:

void winsys_shutdown ( )

Deallocates resources in preparation for program termination.

Author:
jfpatry
Date:
Created: 2000-10-19
Modified: 2000-10-19

Definition at line 195 of file winsys.cpp.

{
    SDL_Quit();
}

Here is the caller graph for this function:

Copies the OpenGL back buffer to the front buffer.

Author:
jfpatry
Date:
Created: 2000-10-19
Modified: 2000-10-19

Definition at line 63 of file winsys.cpp.

{
    SDL_GL_SwapBuffers();
}

Here is the caller graph for this function:

void winsys_warp_pointer ( int  x,
int  y 
)

Moves the mouse pointer to (x,y)

Author:
jfpatry
Date:
Created: 2000-10-19
Modified: 2000-10-19

Definition at line 76 of file winsys.cpp.

{
    SDL_WarpMouse( x, y );
}

Here is the caller graph for this function: