Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 48fdb0e6c5
Fetching contributors…

Cannot retrieve contributors at this time

77 lines (53 sloc) 2.286 kB

SDL's primary purpose is to display graphics. It does so by providing an abstraction called a screen, which represents a video device. This video device is an interface provided by your operating system, such as X11 or DirectX. Before you can display anything, you must create a screen. The SDLx::App class does so for you:

This example causes an empty window to appear on the desktop. Most systems will fill that window with the color black. Other systems might display a transparent window. SDL's default behavior is to fill the screen with black. To enforce this behavior on all systems, you must update() the app to draw to the window:

    $app->update();

SDLx::App Options

SDLx::App allows you to specify several options for the screen and your application. First are the physical dimensions of the screen itself. To make the screen of the SDLx::App window a 400×400 pixel square, change the initialization line to:

    my $app = SDLx::App->new( width => 400, height => 400 );

Another important option is the window's title. Some systems display the path to the running program. Others leave the title blank. You can change the displayed title with another argument to the SDLx::App constructor:

    my $app = SDLx::App->new( width  => 400,
                              height => 400,
                              title  => 'Pong - A clone' );

At this point your screen will be:

Shortcuts

Abbreviations for these parameters are available. Instead of width, height, and title, you may use w, h, and t respectively. The previous example could also be written:

    my $app = SDLx::App->new( w => 400,
                              h => 400,
                              t => 'Pong - A clone' );

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 1:

Unknown directive: =head0

Jump to Line
Something went wrong with that request. Please try again.