Commit | Line | Data |
162a0989 |
1 | <div class="pod"> |
2 | <!-- INDEX START --> |
3 | <h3 id="TOP">Index</h3> |
4 | |
60f74f6f |
5 | <ul><li><a href="#NAME">NAME</a> |
6 | <ul><li><a href="#CATEGORY">CATEGORY</a></li> |
7 | </ul> |
8 | </li> |
162a0989 |
9 | <li><a href="#SYNOPSIS">SYNOPSIS</a></li> |
73000212 |
10 | <li><a href="#SDL_Manual">SDL Manual</a></li> |
162a0989 |
11 | <li><a href="#SDL_BASICS">SDL BASICS</a> |
12 | <ul><li><a href="#Surfaces">Surfaces</a></li> |
13 | <li><a href="#Initialization">Initialization</a></li> |
14 | <li><a href="#Working_With_The_App">Working With The App</a></li> |
15 | </ul> |
16 | </li> |
17 | <li><a href="#SEE_ALSO">SEE ALSO</a></li> |
c7e8d3c6 |
18 | <li><a href="#AUTHORS">AUTHORS</a></li> |
162a0989 |
19 | <li><a href="#COPYRIGHT">COPYRIGHT</a> |
20 | </li> |
21 | </ul><hr /> |
22 | <!-- INDEX END --> |
23 | |
24 | <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p> |
25 | <div id="NAME_CONTENT"> |
26 | <p>SDL::Tutorial - introduction to Perl SDL</p> |
27 | |
28 | </div> |
60f74f6f |
29 | <h2 id="CATEGORY">CATEGORY</h2> |
30 | <div id="CATEGORY_CONTENT"> |
31 | <p>Tutorials</p> |
32 | |
33 | </div> |
162a0989 |
34 | <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
35 | <div id="SYNOPSIS_CONTENT"> |
36 | <pre> # to read this tutorial |
37 | $ perldoc SDL::Tutorial |
38 | |
148a0b32 |
39 | # to run this tutorial |
162a0989 |
40 | $ perl -MSDL::Tutorial -e 1 |
41 | |
42 | </pre> |
43 | |
44 | </div> |
73000212 |
45 | <h1 id="SDL_Manual">SDL Manual</h1><p><a href="#TOP" class="toplink">Top</a></p> |
46 | <div id="SDL_Manual_CONTENT"> |
47 | <p><code>SDL::Tutorial</code> are incomplete and old. A new book has been started to provide |
879fff64 |
48 | a complete tutorial for SDL. See <a href="http://bit.ly/hvxc9V">http://bit.ly/hvxc9V</a>.</p> |
73000212 |
49 | |
50 | </div> |
162a0989 |
51 | <h1 id="SDL_BASICS">SDL BASICS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
52 | <div id="SDL_BASICS_CONTENT"> |
53 | <p>SDL, the Simple DirectMedia Layer, is a cross-platform multimedia library. |
54 | These are the Perl 5 bindings. You can find out more about SDL at |
148a0b32 |
55 | <a href="http://www.libsdl.org/">http://www.libsdl.org/</a>. You can find out more about SDL perl at <a href="http://sdl.perl.org">http://sdl.perl.org</a>.</p> |
162a0989 |
56 | <p>Creating an SDL application with Perl is easy. You have to know a few basics, |
57 | though. Here's how to get up and running as quickly as possible.</p> |
58 | |
59 | </div> |
60 | <h2 id="Surfaces">Surfaces</h2> |
61 | <div id="Surfaces_CONTENT"> |
62 | <p>All graphics in SDL live on a surface. You'll need at least one. That's what |
1dbe1697 |
63 | <a href="SDLx-App.html">SDLx::App</a> provides.</p> |
162a0989 |
64 | <p>Of course, before you can get a surface, you need to initialize your video |
65 | mode. SDL gives you several options, including whether to run in a window or |
66 | take over the full screen, the size of the window, the bit depth of your |
67 | colors, and whether to use hardware acceleration. For now, we'll build |
68 | something really simple.</p> |
69 | |
70 | </div> |
71 | <h2 id="Initialization">Initialization</h2> |
72 | <div id="Initialization_CONTENT"> |
ca0a3441 |
73 | <p>SDLx::App makes it easy to initialize video and create a surface. Here's how to |
162a0989 |
74 | ask for a windowed surface with 640x480x16 resolution:</p> |
ca0a3441 |
75 | <pre> use SDLx::App; |
162a0989 |
76 | |
ca0a3441 |
77 | my $app = SDLx::App->new( |
505f308d |
78 | width => 640, |
79 | height => 480, |
80 | depth => 16, |
162a0989 |
81 | ); |
82 | |
83 | </pre> |
505f308d |
84 | <p>You can get more creative, especially if you use the <code>title</code> and <code>icon</code> |
162a0989 |
85 | attributes in a windowed application. Here's how to set the window title of |
86 | the application to <code>My SDL Program</code>:</p> |
ca0a3441 |
87 | <pre> use SDLx::App; |
162a0989 |
88 | |
ca0a3441 |
89 | my $app = SDLx::App->new( |
505f308d |
90 | height => 640, |
91 | width => 480, |
92 | depth => 16, |
93 | title => 'My SDL Program', |
162a0989 |
94 | ); |
95 | |
96 | </pre> |
97 | <p>Setting an icon is a little more involved -- you have to load an image onto a |
505f308d |
98 | surface. That's a bit more complicated, but see the <code>name</code> parameter to |
162a0989 |
99 | <code>SDL::Surface-</code>new()> if you want to skip ahead.</p> |
100 | |
101 | </div> |
102 | <h2 id="Working_With_The_App">Working With The App</h2> |
103 | <div id="Working_With_The_App_CONTENT"> |
104 | <p>Since <code>$app</code> from the code above is just an SDL surface with some extra sugar, |
55bbf7a2 |
105 | it behaves much like <a href="SDL-Surface.html">SDL::Surface</a>. In particular, the all-important <code>blit</code> |
106 | and <code>update</code> methods work. You'll need to create <a href="SDL-Rect.html">SDL::Rect</a> objects |
162a0989 |
107 | representing sources of graphics to draw onto the <code>$app</code>'s surface, <code>blit</code> |
108 | them there, then <code>update</code> the <code>$app</code>.</p> |
109 | <p><strong>Note:</strong> "blitting" is copying a chunk of memory from one place to another.</p> |
110 | <p>That, however, is another tutorial.</p> |
111 | |
112 | </div> |
113 | <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p> |
114 | <div id="SEE_ALSO_CONTENT"> |
115 | <dl> |
73000212 |
116 | <dt><a href="SDL-Tutorial-Animation.html">SDL::Tutorial::Animation</a></dt> |
162a0989 |
117 | <dd> |
1f5d8082 |
118 | <p>basic rectangle drawing and animation</p> |
162a0989 |
119 | </dd> |
1f5d8082 |
120 | <dt><a href="SDL-Tutorial-LunarLander.html">SDL::Tutorial::LunarLander</a></dt> |
162a0989 |
121 | <dd> |
1f5d8082 |
122 | <p>basic image loading and animation</p> |
162a0989 |
123 | </dd> |
124 | </dl> |
125 | |
126 | </div> |
c7e8d3c6 |
127 | <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
128 | <div id="AUTHORS_CONTENT"> |
1f5d8082 |
129 | <p>chromatic, <chromatic@wgz.org>. </p> |
1dbe1697 |
130 | <p>Written for and maintained by the Perl SDL project, <a href="http://sdl.perl.org/">http://sdl.perl.org/</a>. See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a> for details.</p> |
162a0989 |
131 | |
132 | </div> |
133 | <h1 id="COPYRIGHT">COPYRIGHT</h1><p><a href="#TOP" class="toplink">Top</a></p> |
134 | <div id="COPYRIGHT_CONTENT"> |
1f5d8082 |
135 | <p>Copyright (c) 2003 - 2004, chromatic. 2009 - 2010, kthakore. All rights reserved. This module is |
162a0989 |
136 | distributed under the same terms as Perl itself, in the hope that it is useful |
137 | but certainly under no guarantee. |
138 | </p> |
139 | |
140 | </div> |
141 | </div> |