X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDLx-App.html-inc;h=8db7209400f3db73f901fb9904ea798d53b08d86;hb=a3de848879a5553418ed11fb193c4bf286ca7120;hp=b1f6592f5736c5d96131ef23e62a463558886b47;hpb=505f308d8b092747da8b2f5e9781475a1f06dfe8;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDLx-App.html-inc b/pages/SDLx-App.html-inc index b1f6592..8db7209 100644 --- a/pages/SDLx-App.html-inc +++ b/pages/SDLx-App.html-inc @@ -8,20 +8,26 @@
  • DESCRIPTION
  • METHODS +
  • +
  • METHODS +
  • -
  • AUTHOR
  • +
  • CALLBACKS
  • +
  • AUTHORS
  • SEE ALSO

  • @@ -52,7 +58,7 @@ ); -

    This is the manual way of doing things

    +

    This is the manual way of doing things

        my $event = SDL::Event->new; # create a new event 
     
         SDL::Events::pump_events();
    @@ -64,7 +70,7 @@
         }
     
     
    -

    An alternative to the manual Event processing is the SDLx::App::loop .

    +

    An alternative to the manual Event processing is through the SDLx::Controller module. SDLx::App is a Controller so see the CALLBACKS section below.

    DESCRIPTION

    Top

    @@ -83,30 +89,49 @@ manager oriented functions.

    SDLx::App::new initializes the SDL, creates a new screen, and initializes some of the window manager properties. SDLx::App::new takes a series of named parameters:

    - +
    +
    * title +the window title. Defaults to the file name. Shorter alias: 't'
    +
    * icon_title +the icon title. Defaults to file name. Shortcut: 'it'
    +
    * icon +the icon itself. Defaults to none. Shortcut: 'i'
    +
    * width +Window width, in pixels. Defaults to 800. Shortcut: 'w'
    +
    * height +Window height, in pixels. Defaults to 600. Shortcut: 'h'
    +
    * depth +Screen depth. Defaults to 16. Shortcut: 'd'.
    +
    * flags +Any flags you want to pass to SDL::Video upon initialization. Defaults to SDL_ANYFORMAT. Flags should be or'ed together if you're passing more than one (flags => FOO|BAR). Shortcut: 'f'.
    +
    * resizeable +Set this to a true value to make the window resizeable by the user. Default is off.
    +
    + +

    METHODS

    Top

    +
    -

    title

    +

    title()

    -

    SDLx::App::title takes 0, 1, or 2 arguments. It returns the current -application window title. If one parameter is passed, both the window -title and icon title will be set to its value. If two parameters are -passed the window title will be set to the first, and the icon title -to the second.

    -

    delay

    -
    +

    title( $new_title )

    +
    + +
    +

    title( $window_title, $icon_title )

    +
    +

    SDLx::App::title takes 0, 1, or 2 arguments. If no parameter is given, +it returns the current application window title. If one parameter is +passed, both the window title and icon title will be set to its value. +If two parameters are passed the window title will be set to the first, +and the icon title to the second.

    + +
    +

    delay( $ms )

    +

    SDLx::App::delay takes 1 argument, and will sleep the application for that many ms.

    @@ -121,10 +146,10 @@ that many ms.

    SDLx::App::error returns the last error message set by the SDL.

    -

    resize

    -
    -

    SDLx::App::resize takes a new height and width of the application -if the application was originally created with the resizable option.

    +

    resize( $width, $height )

    +
    +

    SDLx::App::resize takes a new width and height of the application. Only +works if the application was originally created with the resizable option.

    fullscreen

    @@ -134,65 +159,66 @@ if the application was originally created with the resizable option.

    iconify

    -

    SDLx::App::iconify iconifies the applicaiton window.

    +

    SDLx::App::iconify iconifies the application window.

    -

    grab_input

    -
    +

    grab_input( $CONSTANT )

    +

    SDLx::App::grab_input can be used to change the input focus behavior of -the application. It takes one argument, which should be one of the following:

    +the application. It takes one argument, which should be one of the following:

    -
    * -SDL_GRAB_QUERY
    -
    * -SDL_GRAB_ON
    -
    * -SDL_GRAB_OFF
    +
    * SDL_GRAB_QUERY
    +
    * SDL_GRAB_ON
    +
    * SDL_GRAB_OFF
    -

    loop

    -
    -

    SDLx::App::loop is a simple event loop method which takes a reference to a hash -of event handler subroutines. The keys of the hash must be SDL event types such -as SDL_QUIT(), SDL_KEYDOWN(), and the like. The event method recieves as its parameter -the event object used in the loop.

    -

    Example:

    -
        my $app = SDLx::App->new(
    -        title  => "test.app", 
    -        width  => 800, 
    -        height => 600, 
    -        depth  => 32
    -    );
    -
    -    my %actions = (
    -        SDL_QUIT()    => sub { exit(0); },
    -        SDL_KEYDOWN() => sub { print "Key Pressed" },
    -    );
    -
    -    $app->loop( \%actions );
    -
    -
    - -

    sync

    SDLx::App::sync encapsulates the various methods of syncronizing the screen with the -current video buffer. SDLx::App::sync will do a fullscreen update, using the double buffer -or OpenGL buffer if applicable. This is prefered to calling flip on the application window.

    +current video buffer. SDLx::App::sync will do a fullscreen update, using the double buffer +or OpenGL buffer if applicable. This is prefered to calling flip on the application window.

    + +
    +

    attribute( $attr )

    +
    -

    attribute ( attr, [value] )

    +

    attribute( $attr, $value )

    -

    SDLx::App::attribute allows one to set and get GL attributes. By passing a value -in addition to the attribute selector, the value will be set. SDL:::App::attribute -always returns the current value of the given attribute, or croaks on failure.

    +

    SDLx::App::attribute allows one to get and set GL attributes. By passing a value +in addition to the attribute selector, the value will be set. SDL:::App::attribute +always returns the current value of the given attribute, or Carp::confesss on failure.

    + +
    +

    CALLBACKS

    Top

    +
    +

    SDLx::App is a SDLx::Controller. Use the event, show and handlers to run the app.

    +
      use SDL;
    +  use SDLx::App;
    +
    +  use SDL::Event; #Where ever the event call back is processed
    +
    +  my $app = SDLx::App->new( width => 200, height => 200);
    +
    +  $app->add_event_handler( sub{ return 0 if $_[0]->type == SDL_QUIT; return 1});
    +
    +  $app->add_show_handler( sub{ $app->update() } );
    +
    +  $app->add_move_handler( 
    +  sub{ 
    +  #calc your physics here 
    +  } );
    +
    +  $app->run();
    +
    +
    +

    see SDLx::Controller for more details.

    -

    AUTHOR

    Top

    -
    -

    David J. Goehrig -Kartik Thakore

    +

    AUTHORS

    Top

    +
    +

    See AUTHORS in SDL.

    SEE ALSO

    Top