pods::SDLx::App(3pm)
๐ NAME ๐
SDLx::App โ a SDL perl extension ๐
(also hiii, you're reading pods::SDLx::App(3pm) from the pods manual โ welcome, bestie ๐ซถ)
๐ 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
);
That's the manual way of doing things, okay ๐
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;
}
But likeโฆ there's an alternative to manually wrangling all those Events: the SDLx::Controller module ๐ฎ. SDLx::App is a Controller, so peep the CALLBACKS section down below, iykyk ๐
๐ธ DESCRIPTION ๐ธ
SDLx::App controls the root window of your SDL-based application โ main character energy fr fr ๐. It extends the SDL::Surface class and hands you an interface to all the window-manager-oriented functions. Literally so convenient ๐
โจ METHODS โจ
๐ new
SDLx::App::new initializes the SDL, creates a new screen, and sets up some of the window manager properties. SDLx::App::new takes a whole lineup of named parameters, bestie:
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 to800. Shortcut:'w'heightโ Window height, in pixels. Defaults to600. Shortcut:'h'depthโ Screen depth. Defaults to16. Shortcut:'d'.flagsโ Any flags you want to pass toSDL::Videoupon initialization. Defaults toSDL_ANYFORMAT. Flags should be or'ed together if you're passing more than one (flags => FOO|BAR). Shortcut:'f'. ๐ฉresizableโ Set this to a true value to make the window resizable by the user. Default is off.exit_on_quitโ Set this to a true value to make the app exit if aSDL_QUITevent is triggered. Shortcut:'eoq'. ๐ช
๐ METHODS ๐
(part two, electric boogaloo โ the getters and tools ๐)
๐ title()
๐ title( $new_title )
๐ title( $window_title, $icon_title )
title()
title( $new_title )
title( $window_title, $icon_title )
SDLx::App::title takes 0, 1, or 2 arguments, no more no less ๐ค. If no parameter is given, it returns the current application window title. If one parameter is passed, both the window title and the icon title get set to its value. If two parameters are passed, the window title becomes the first one and the icon title becomes the second. Iconic behaviour honestly ๐
โณ delay( $ms )
SDLx::App::delay takes 1 argument and will sleep the application for that many ms. Nap time bestie ๐ด
โฑ๏ธ ticks
SDLx::App::ticks returns the number of ms since the application began. Time flies fr ๐ฐ๏ธ
๐ error
SDLx::App::error returns the last error message set by the SDL.
๐ resize( $width, $height )
SDLx::App::resize takes a new width and height of the application. Heads up tho โ it 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. Big screen mode activated ๐ฅ
๐ iconify
SDLx::App::iconify iconifies the application window.
๐ฏ 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 these three constants:
SDL_GRAB_QUERYSDL_GRAB_ONSDL_GRAB_OFF
๐ sync
SDLx::App::sync encapsulates the various methods of synchronizing 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 preferred to calling flip on the application window โ so like, use this one, okay? ๐
๐ง attribute( $attr )
๐ง attribute( $attr, $value )
SDLx::App::attribute lets you get and set GL attributes. Pass a value alongside the attribute selector and the value gets set. SDL:::App::attribute always returns the current value of the given attribute, or Carp::confess on failure ๐ญ (yes, that's how it's written, don't come for me)
๐ 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{
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();
see SDLx::Controller for more details. Go read it, it's giving essential lore ๐
๐ AUTHORS ๐
See "AUTHORS" in SDL.
๐ SEE ALSO ๐
perl SDL::Surface SDL::Event SDL::OpenGL
ok that's the whole page bestie, you ate that ๐ซถ๐ go build something iconic โจ
anddd for the record, this was perl v5.42.3, dated 2026-08-19, and it's the pods::SDLx::App(3pm) page โ mwah, bye! ๐๐๐
๐ฆ where this page comes from
- ubuntu stonking: libsdl-perl 2.548-6build1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms