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.
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,
update() the app to draw to the window:
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
my $app = SDLx::App->new( width => 400, height => 400, title => 'Pong - A clone' );
At this point your screen will be:
Abbreviations for these parameters are available. Instead of
title, you may use
t respectively. The previous example could also be written:
my $app = SDLx::App->new( w => 400, h => 400, t => 'Pong - A clone' );
Hey! The above document had some coding errors, which are explained below:
- Around line 1:
Unknown directive: =head0