1SDL::Tutorial(3)      User Contributed Perl Documentation     SDL::Tutorial(3)
2
3
4

NAME

6       SDL::Tutorial - introduction to Perl SDL
7

SYNOPSIS

9               # to read this tutorial
10               $ perldoc SDL::Tutorial
11
12               # to create a bare-bones SDL app based on this tutorial
13               $ perl -MSDL::Tutorial=basic_app.pl -e 1
14

SDL BASICS

16       SDL, the Simple DirectMedia Layer, is a cross-platform multimedia
17       library.  These are the Perl 5 bindings.  You can find out more about
18       SDL at <http://www.libsdl.org/>.
19
20       Creating an SDL application with Perl is easy.  You have to know a few
21       basics, though.  Here's how to get up and running as quickly as
22       possible.
23
24   Surfaces
25       All graphics in SDL live on a surface.  You'll need at least one.
26       That's what SDL::App provides.
27
28       Of course, before you can get a surface, you need to initialize your
29       video mode.  SDL gives you several options, including whether to run in
30       a window or take over the full screen, the size of the window, the bit
31       depth of your colors, and whether to use hardware acceleration.  For
32       now, we'll build something really simple.
33
34   Initialization
35       SDL::App makes it easy to initialize video and create a surface.
36       Here's how to ask for a windowed surface with 640x480x16 resolution:
37
38               use SDL::App;
39
40               my $app = SDL::App->new(
41                       -width  => 640,
42                       -height => 480,
43                       -depth  => 16,
44               );
45
46       You can get more creative, especially if you use the "-title" and
47       "-icon" attributes in a windowed application.  Here's how to set the
48       window title of the application to "My SDL Program":
49
50               use SDL::App;
51
52               my $app = SDL::App->new(
53                       -height => 640,
54                       -width  => 480,
55                       -depth  => 16,
56                       -title  => 'My SDL Program',
57               );
58
59       Setting an icon is a little more involved -- you have to load an image
60       onto a surface.  That's a bit more complicated, but see the "-name"
61       parameter to "SDL::Surface-"new()> if you want to skip ahead.
62
63   Working With The App
64       Since $app from the code above is just an SDL surface with some extra
65       sugar, it behaves much like SDL::Surface.  In particular, the all-
66       important "blit" and "update" methods work.  You'll need to create
67       SDL::Rect objects representing sources of graphics to draw onto the
68       $app's surface, "blit" them there, then "update" the $app.
69
70       Note:  "blitting" is copying a chunk of memory from one place to
71       another.
72
73       That, however, is another tutorial.
74

SEE ALSO

76       SDL::Tutorial::Drawing
77           basic drawing with rectangles
78
79       SDL::Tutorial::Animation
80           basic rectangle animation
81
82       SDL::Tutorial::Images
83           image loading and animation
84

AUTHOR

86       chromatic, <chromatic@wgz.org>.
87
88       Written for and maintained by the Perl SDL project,
89       <http://sdl.perl.org/>.
90
92       Copyright (c) 2003 - 2004, chromatic.  All rights reserved.  This
93       module is distributed under the same terms as Perl itself, in the hope
94       that it is useful but certainly under no guarantee.
95
96
97
98perl v5.12.0                      2010-05-06                  SDL::Tutorial(3)
Impressum