3 use Pod::ToDemo <<'END_HERE';
6 # change these values as necessary
7 my $title = 'My SDL App';
8 my ($width, $height, $depth) = ( 640, 480, 16 );
10 my $app = SDL::App->new(
17 # your code here; remove the next line
27 SDL::Tutorial - introduction to Perl SDL
31 # to read this tutorial
32 $ perldoc SDL::Tutorial
34 # to create a bare-bones SDL app based on this tutorial
35 $ perl -MSDL::Tutorial=basic_app.pl -e 1
39 SDL, the Simple DirectMedia Layer, is a cross-platform multimedia library.
40 These are the Perl 5 bindings. You can find out more about SDL at
41 L<http://www.libsdl.org/>.
43 Creating an SDL application with Perl is easy. You have to know a few basics,
44 though. Here's how to get up and running as quickly as possible.
48 All graphics in SDL live on a surface. You'll need at least one. That's what
51 Of course, before you can get a surface, you need to initialize your video
52 mode. SDL gives you several options, including whether to run in a window or
53 take over the full screen, the size of the window, the bit depth of your
54 colors, and whether to use hardware acceleration. For now, we'll build
55 something really simple.
59 SDL::App makes it easy to initialize video and create a surface. Here's how to
60 ask for a windowed surface with 640x480x16 resolution:
64 my $app = SDL::App->new(
70 You can get more creative, especially if you use the C<-title> and C<-icon>
71 attributes in a windowed application. Here's how to set the window title of
72 the application to C<My SDL Program>:
76 my $app = SDL::App->new(
80 -title => 'My SDL Program',
83 Setting an icon is a little more involved -- you have to load an image onto a
84 surface. That's a bit more complicated, but see the C<-name> parameter to
85 C<SDL::Surface->new()> if you want to skip ahead.
87 =head2 Working With The App
89 Since C<$app> from the code above is just an SDL surface with some extra sugar,
90 it behaves much like L<SDL::Surface>. In particular, the all-important C<blit>
91 and C<update> methods work. You'll need to create L<SDL::Rect> objects
92 representing sources of graphics to draw onto the C<$app>'s surface, C<blit>
93 them there, then C<update> the C<$app>.
95 B<Note:> "blitting" is copying a chunk of memory from one place to another.
97 That, however, is another tutorial.
103 =item L<SDL::Tutorial::Drawing>
105 basic drawing with rectangles
107 =item L<SDL::Tutorial::Animation>
109 basic rectangle animation
111 =item L<SDL::Tutorial::Images>
113 image loading and animation
119 chromatic, E<lt>chromatic@wgz.orgE<gt>.
121 Written for and maintained by the Perl SDL project, L<http://sdl.perl.org/>.
125 Copyright (c) 2003 - 2004, chromatic. All rights reserved. This module is
126 distributed under the same terms as Perl itself, in the hope that it is useful
127 but certainly under no guarantee.