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

NAME

6       SDL::Tutorial - introduction to Perl SDL
7
8   CATEGORY
9       Tutorials
10

SYNOPSIS

12               # to read this tutorial
13               $ perldoc SDL::Tutorial
14
15               # to run this tutorial
16               $ perl -MSDL::Tutorial -e 1
17

SDL Manual

19       "SDL::Tutorial" are incomplete and old. A new book has been started to
20       provide a complete tutorial for SDL. See <http://bit.ly/hvxc9V>.
21

SDL BASICS

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

SEE ALSO

84       SDL::Tutorial::Animation
85           basic rectangle drawing and animation
86
87       SDL::Tutorial::LunarLander
88           basic image loading and animation
89

AUTHORS

91       chromatic, <chromatic@wgz.org>.
92
93       Written for and maintained by the Perl SDL project,
94       <http://sdl.perl.org/>. See "AUTHORS" in SDL for details.
95
97       Copyright (c) 2003 - 2004, chromatic. 2009 - 2010, kthakore.  All
98       rights reserved.  This module is distributed under the same terms as
99       Perl itself, in the hope that it is useful but certainly under no
100       guarantee.
101
102
103
104perl v5.28.0                      2018-07-15                  SDL::Tutorial(3)
Impressum