X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDLx-App.html-inc;h=a8127cfd0f1897f90fff9f8af2e86be4665c9162;hb=1dbe16975541da864f8bfa5169c89a2ab8893bf2;hp=72ae752fba01a4edf48a22c36061b6a175bb50e6;hpb=285d0cd289790209bcd9d141d63fd6fce74a2ee4;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDLx-App.html-inc b/pages/SDLx-App.html-inc index 72ae752..a8127cf 100644 --- a/pages/SDLx-App.html-inc +++ b/pages/SDLx-App.html-inc @@ -8,7 +8,10 @@
  • DESCRIPTION
  • METHODS +
  • +
  • METHODS +
  • -
  • AUTHOR
  • +
  • CALLBACKS
  • +
  • AUTHORS
  • SEE ALSO

  • @@ -67,12 +70,12 @@ } -

    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

    -

    SDLx::App controls the root window of the of your SDL based application. +

    SDLx::App controls the root window of the of your SDL based application. It extends the SDL::Surface class, and provides an interface to the window manager oriented functions.

    @@ -87,19 +90,27 @@ manager oriented functions.

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

    -
    * title
    -
    * icon_title
    -
    * icon
    -
    * width
    -
    * height
    -
    * depth
    -
    * flags
    -
    * resizeable
    +
    * 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()

    @@ -162,30 +173,6 @@ the application. It takes one argument, which should be one of the following:

    -

    loop( \%actions )

    -
    -

    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. When called, 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 @@ -201,13 +188,37 @@ or OpenGL buffer if applicable. This is prefered to calling flip on the applicat

    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 croaks on failure.

    +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 ALSO

    Top