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 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'. ๐Ÿšฉ
  • 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 a SDL_QUIT event 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_QUERY
  • SDL_GRAB_ON
  • SDL_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