.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "pods::SDLx::App 3pm" .TH pods::SDLx::App 3pm 2024-03-28 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME SDLx::App \- a SDL perl extension .SH CATEGORY .IX Header "CATEGORY" Extension .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 4 \& use SDL; \& use SDLx::App; \& use SDL::Event; \& use SDL::Events; \& \& my $app = SDLx::App\->new( \& title => \*(AqApplication Title\*(Aq, \& width => 640, \& height => 480, \& depth => 32 \& ); .Ve .PP This is the manual way of doing things .PP .Vb 1 \& 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; \& } .Ve .PP An alternative to the manual Event processing is through the SDLx::Controller module. SDLx::App is a Controller so see the CALLBACKS section below. .SH DESCRIPTION .IX Header "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. .SH METHODS .IX Header "METHODS" .SS new .IX Subsection "new" \&\f(CW\*(C`SDLx::App::new\*(C'\fR initializes the SDL, creates a new screen, and initializes some of the window manager properties. \&\f(CW\*(C`SDLx::App::new\*(C'\fR takes a series of named parameters: .IP \(bu 4 title the window title. Defaults to the file name. Shorter alias: 't' .IP \(bu 4 icon_title the icon title. Defaults to file name. Shortcut: 'it' .IP \(bu 4 icon the icon itself. Defaults to none. Shortcut: 'i' .IP \(bu 4 width Window width, in pixels. Defaults to 800. Shortcut: 'w' .IP \(bu 4 height Window height, in pixels. Defaults to 600. Shortcut: 'h' .IP \(bu 4 depth Screen depth. Defaults to 16. Shortcut: 'd'. .IP \(bu 4 flags Any flags you want to pass to SDL::Video upon initialization. Defaults to SDL_ANYFORMAT. Flags should be \fIor'ed\fR together if you're passing more than one (flags => FOO|BAR). Shortcut: 'f'. .IP \(bu 4 resizable Set this to a true value to make the window resizable by the user. Default is off. .IP \(bu 4 exit_on_quit Set this to a true value to make the app exit if a SDL_QUIT event is triggered. Shortcut: 'eoq'. .SH METHODS .IX Header "METHODS" .SS \fBtitle()\fP .IX Subsection "title()" .ie n .SS "title( $new_title )" .el .SS "title( \f(CW$new_title\fP )" .IX Subsection "title( $new_title )" .ie n .SS "title( $window_title, $icon_title )" .el .SS "title( \f(CW$window_title\fP, \f(CW$icon_title\fP )" .IX Subsection "title( $window_title, $icon_title )" \&\f(CW\*(C`SDLx::App::title\*(C'\fR 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. .ie n .SS "delay( $ms )" .el .SS "delay( \f(CW$ms\fP )" .IX Subsection "delay( $ms )" \&\f(CW\*(C`SDLx::App::delay\*(C'\fR takes 1 argument, and will sleep the application for that many ms. .SS ticks .IX Subsection "ticks" \&\f(CW\*(C`SDLx::App::ticks\*(C'\fR returns the number of ms since the application began. .SS error .IX Subsection "error" \&\f(CW\*(C`SDLx::App::error\*(C'\fR returns the last error message set by the SDL. .ie n .SS "resize( $width, $height )" .el .SS "resize( \f(CW$width\fP, \f(CW$height\fP )" .IX Subsection "resize( $width, $height )" \&\f(CW\*(C`SDLx::App::resize\*(C'\fR takes a new width and height of the application. Only works if the application was originally created with the resizable option. .SS fullscreen .IX Subsection "fullscreen" \&\f(CW\*(C`SDLx::App::fullscreen\*(C'\fR toggles the application in and out of fullscreen mode. .SS iconify .IX Subsection "iconify" \&\f(CW\*(C`SDLx::App::iconify\*(C'\fR iconifies the application window. .ie n .SS "grab_input( $CONSTANT )" .el .SS "grab_input( \f(CW$CONSTANT\fP )" .IX Subsection "grab_input( $CONSTANT )" \&\f(CW\*(C`SDLx::App::grab_input\*(C'\fR can be used to change the input focus behavior of the application. It takes one argument, which should be one of the following: .IP \(bu 4 SDL_GRAB_QUERY .IP \(bu 4 SDL_GRAB_ON .IP \(bu 4 SDL_GRAB_OFF .SS sync .IX Subsection "sync" \&\f(CW\*(C`SDLx::App::sync\*(C'\fR encapsulates the various methods of synchronizing the screen with the current video buffer. \f(CW\*(C`SDLx::App::sync\*(C'\fR will do a fullscreen update, using the double buffer or OpenGL buffer if applicable. This is preferred to calling flip on the application window. .ie n .SS "attribute( $attr )" .el .SS "attribute( \f(CW$attr\fP )" .IX Subsection "attribute( $attr )" .ie n .SS "attribute( $attr, $value )" .el .SS "attribute( \f(CW$attr\fP, \f(CW$value\fP )" .IX Subsection "attribute( $attr, $value )" \&\f(CW\*(C`SDLx::App::attribute\*(C'\fR allows one to get and set GL attributes. By passing a value in addition to the attribute selector, the value will be set. \f(CW\*(C`SDL:::App::attribute\*(C'\fR always returns the current value of the given attribute, or Carp::confess on failure. .SH CALLBACKS .IX Header "CALLBACKS" \&\f(CW\*(C`SDLx::App\*(C'\fR is a \f(CW\*(C`SDLx::Controller\*(C'\fR. Use the event, show and handlers to run the app. .PP .Vb 2 \& 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{ \& my ($event, $app) = @_; \& return $_[0]\->type == SDL_QUIT ? 0 : 1; \& }); \& \& $app\->add_show_handler( sub{ \& my ($delta, $app) = @_; \& $app\->update; \& } ); \& \& $app\->add_move_handler( sub{ \& my ($step, $app, $t) = @_; \& #calc your physics here \& } ); \& \& $app\->run(); .Ve .PP see SDLx::Controller for more details. .SH AUTHORS .IX Header "AUTHORS" See "AUTHORS" in SDL. .SH "SEE ALSO" .IX Header "SEE ALSO" perl SDL::Surface SDL::Event SDL::OpenGL