GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PODS::SDLX::APP (3)

.ds Aq ’

NAME

SDLx::App - a SDL perl extension

CONTENTS

CATEGORY

Extension

SYNOPSIS



    use SDL;
    use SDLx::App;
    use SDL::Event;
    use SDL::Events;
   
    my $app = SDLx::App->new(
        title  => Application Title,
        width  => 640,
        height => 480,
        depth  => 32
    );



This is the manual way of doing things



    my $event = SDL::Event->new; # create a new event
   
    SDL::Events::pump_events();
      
    while ( SDL::Events::poll_event($event) ) {
        my $type = $event->type(); # get event type
        print $type;
        exit if $type == SDL_QUIT;
    }



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

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.

METHODS

    new

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:
o title the window title. Defaults to the file name. Shorter alias: ’t’
o icon_title the icon title. Defaults to file name. Shortcut: ’it’
o icon the icon itself. Defaults to none. Shortcut: ’i’
o width Window width, in pixels. Defaults to 800. Shortcut: ’w’
o height Window height, in pixels. Defaults to 600. Shortcut: ’h’
o depth Screen depth. Defaults to 16. Shortcut: ’d’.
o 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’.
o resizeable Set this to a true value to make the window resizeable by the user. Default is off.
o exit_on_quit Set this to a true value to make the app exit if a SDL_QUIT event is triggered. Shortcut: ’eoq’.

METHODS

title()

title( CW$new_title )

title( CW$window_title, CW$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( CW$ms )

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

    ticks

SDLx::App::ticks returns the number of ms since the application began.

    error

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

resize( CW$width, CW$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

SDLx::App::fullscreen toggles the application in and out of fullscreen mode.

    iconify

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

grab_input( CW$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:
o SDL_GRAB_QUERY
o SDL_GRAB_ON
o SDL_GRAB_OFF

    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.

attribute( CW$attr )

attribute( CW$attr, CW$value )

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

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.

AUTHORS

See AUTHORS in SDL.

SEE ALSO

perl SDL::Surface SDL::Event SDL::OpenGL
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PODS::SDLX::APP (3) 2016-04-05

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.