updated docs
[sdlgit/SDL-Site.git] / pages / SDL.html-inc
1 <div class="pod">
2 <!-- INDEX START -->
3 <h3 id="TOP">Index</h3>
4
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#CATEGORY">CATEGORY</a></li>
7 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
8 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
9 <li><a href="#CONSTANTS">CONSTANTS</a></li>
10 <li><a href="#METHODS">METHODS</a>
11 <ul><li><a href="#init">init</a></li>
12 <li><a href="#init_subsystem">init_subsystem</a></li>
13 <li><a href="#quit_subsystem">quit_subsystem</a></li>
14 <li><a href="#quit">quit</a></li>
15 <li><a href="#was_init">was_init</a></li>
16 <li><a href="#get_error">get_error</a></li>
17 <li><a href="#set_error_real">set_error_real</a></li>
18 <li><a href="#clear_error">clear_error</a></li>
19 <li><a href="#version">version</a></li>
20 <li><a href="#linked_version">linked_version</a></li>
21 <li><a href="#get_ticks">get_ticks</a></li>
22 <li><a href="#delay">delay</a></li>
23 </ul>
24 </li>
25 <li><a href="#AUTHORS">AUTHORS</a>
26 <ul><li><a href="#Project_Founder">Project Founder</a></li>
27 <li><a href="#Current_Maintainers">Current Maintainers</a></li>
28 <li><a href="#Core_Developers_and_Contributors">Core Developers and Contributors</a></li>
29 </ul>
30 </li>
31 <li><a href="#COPYRIGHT_amp_LICENSE">COPYRIGHT &amp; LICENSE</a></li>
32 <li><a href="#DISCLAIMER_OF_WARRANTY">DISCLAIMER OF WARRANTY</a>
33 </li>
34 </ul><hr />
35 <!-- INDEX END -->
36
37 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
38 <div id="NAME_CONTENT">
39 <p>SDL - Simple DirectMedia Layer for Perl</p>
40
41 </div>
42 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
43 <div id="CATEGORY_CONTENT">
44 <p>Core</p>
45
46 </div>
47 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
48 <div id="SYNOPSIS_CONTENT">
49 <pre> use SDL;
50
51 </pre>
52
53 </div>
54 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
55 <div id="DESCRIPTION_CONTENT">
56 <p>SDL_perl is a package of Perl modules that provide both functional and object oriented interfaces to the Simple DirectMedia Layer for Perl 5.
57 This package takes some liberties with the SDL API, and attempts to adhere to the spirit of both the SDL and Perl.
58 This document describes the low-level functional SDL Perl API.
59 For the object oriented programming interface please see the documentation provided on a per-class basis.</p>
60
61 </div>
62 <h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
63 <div id="CONSTANTS_CONTENT">
64 <p>The constants are not exported by default. You can export them by doing:</p>
65 <pre> use SDL ':all';
66
67 </pre>
68 <p>or access them directly:</p>
69 <pre> SDL::SDL_INIT_AUDIO;
70
71 </pre>
72 <p>or by choosing the export tags below:</p>
73 <p>Export tag: ':init'</p>
74 <pre> SDL_INIT_AUDIO
75  SDL_INIT_VIDEO
76  SDL_INIT_CDROM
77  SDL_INIT_EVERYTHING
78  SDL_INIT_NOPARACHUTE
79  SDL_INIT_JOYSTICK
80  SDL_INIT_TIMER
81
82 </pre>
83
84 </div>
85 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
86 <div id="METHODS_CONTENT">
87
88 </div>
89 <h2 id="init">init</h2>
90 <div id="init_CONTENT">
91 <pre> SDL::init( $flags );
92
93 </pre>
94 <p>As with the C language API, SDL Perl initializes the SDL environment with the <code>SDL::init</code> subroutine.
95 This routine takes a mode flag constructed through the bitwise OR product of the <code>SDL_INIT_*</code> constants.
96 The <code>$flags</code> tell <code>SDL::init</code> which subsystems to initialize.</p>
97 <pre> SDL::init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
98
99 </pre>
100 <p><code>SDL::init</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
101
102 </div>
103 <h2 id="init_subsystem">init_subsystem</h2>
104 <div id="init_subsystem_CONTENT">
105 <pre> SDL::init_subsystem( $flags );
106
107 </pre>
108 <p>After SDL has been initialized with <code>SDL::init</code> you may initialize any uninitialized subsystems with <code>SDL::init_subsystem</code>.
109 The <code>$flags</code> tell <code>SDL::init_subsystem</code> which subsystems to initialize, and are taken in the same way as <code>SDL::init</code>.</p>
110 <p><code>SDL::init_subsystem</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
111
112 </div>
113 <h2 id="quit_subsystem">quit_subsystem</h2>
114 <div id="quit_subsystem_CONTENT">
115 <pre> SDL::quit_subsystem( $flags );
116
117 </pre>
118 <p><code>SDL::quit_subsystem</code> allows you to shut down a subsystem that has been previously initialized by <code>SDL::init</code> or <code>SDL::init_subsystem</code>.
119 The <code>$flags</code> tell <code>SDL::quit_subsystem</code> which subsystems to shut down, and are taken in the same way as <code>SDL::init</code>.</p>
120 <p><code>SDL::quit_subsystem</code> doesn't return any values.</p>
121
122 </div>
123 <h2 id="quit">quit</h2>
124 <div id="quit_CONTENT">
125 <pre> SDL::quit;
126
127 </pre>
128 <p><code>SDL::quit</code> Shuts down all SDL subsystems, unloads the dynamically linked library and frees the allocated resources.</p>
129 <p><strong>Note:</strong> This will be called automatically when Perl exits. You don't need to call this, except if you want to initialize SDL again after this.</p>
130 <p><code>SDL::quit</code> doesn't return any values.</p>
131
132 </div>
133 <h2 id="was_init">was_init</h2>
134 <div id="was_init_CONTENT">
135 <pre> my $flags = SDL::was_init( $flags );
136
137 </pre>
138 <p><code>SDL::was_init</code> allows you to see which SDL subsytems have been initialized.
139 The <code>$flags</code> tell <code>SDL::was_init</code> which subsystems to check, and are taken in the same way as <code>SDL::init</code>.</p>
140 <p><code>SDL::was_init</code> returns a mask of the initialized subsystems it checks.
141 If <code>$flags</code> is <code>0</code> or <code>SDL_INIT_EVERYTHING</code>, a mask of all initialized subsystems will be returned (this does not include <code>SDL_INIT_EVENTTHREAD</code> or <code>SDL_INIT_NOPARACHUTE</code>).</p>
142 <pre> use SDL ':all';
143
144  my $mask = SDL::was_init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
145  if($mask &amp; SDL_INIT_AUDIO and $mask &amp; SDL_INIT_JOYSTICK) {
146      # Both subsystems are initialized!
147  }
148
149 </pre>
150
151 </div>
152 <h2 id="get_error">get_error</h2>
153 <div id="get_error_CONTENT">
154 <pre> my $error = SDL::get_error;
155
156 </pre>
157 <p>Returns a scalar value containing the last error message set by the SDL library (if any).</p>
158
159 </div>
160 <h2 id="set_error_real">set_error_real</h2>
161 <div id="set_error_real_CONTENT">
162 <pre> SDL::set_error_real( $printf_format, @values )
163
164 </pre>
165 <p><code>SDL::set_error_real</code> sets the SDL error to a <code>printf</code> style formatted string.</p>
166 <p><code>SDL::set_error_real</code> doesn't return any values.</p>
167
168 </div>
169 <h2 id="clear_error">clear_error</h2>
170 <div id="clear_error_CONTENT">
171 <pre> SDL::clear_error;
172
173 </pre>
174 <p><code>SDL::clear_error</code> deletes all information about the last SDL error.
175 This is useful if the error has been handled by the program.</p>
176 <p><code>SDL::clear_error</code> doesn't return any values.</p>
177
178 </div>
179 <h2 id="version">version</h2>
180 <div id="version_CONTENT">
181 <pre> my $version = SDL::version;
182
183 </pre>
184 <p>Returns an <code>SDL::Version</code> object of the SDL library at compile-time.</p>
185 <pre> use SDL;
186  use SDL::Version;
187
188  my $v = SDL::version;
189  printf(&quot;got version: %d.%d.%d\n&quot;, $v-&gt;major, $v-&gt;minor, $v-&gt;patch);
190
191 </pre>
192
193 </div>
194 <h2 id="linked_version">linked_version</h2>
195 <div id="linked_version_CONTENT">
196 <p><code>SDL::linked_version</code> works in the same way as <code>SDL::version</code>, but returns an <code>SDL::Version</code> object of the SDL library at link-time.</p>
197
198 </div>
199 <h2 id="get_ticks">get_ticks</h2>
200 <div id="get_ticks_CONTENT">
201 <pre> my $ticks = SDL::get_ticks;
202
203 </pre>
204 <p>Returns the number of milliseconds since SDL library initialization.
205 This value wraps around if the program runs for more than 49.7 days</p>
206
207 </div>
208 <h2 id="delay">delay</h2>
209 <div id="delay_CONTENT">
210 <pre> SDL::delay( $ms );
211
212 </pre>
213 <p><code>SDL::delay</code> waits the specified number of milliseconds before returning.
214 The actual delay may be longer than specified depending on the underlying OS.</p>
215 <p><code>SDL::delay</code> doesn't return anything.</p>
216 <pre> # Delay for half a second
217  SDL::delay(500);
218
219 </pre>
220
221 </div>
222 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
223 <div id="AUTHORS_CONTENT">
224
225 </div>
226 <h2 id="Project_Founder">Project Founder</h2>
227 <div id="Project_Founder_CONTENT">
228 <p>David J. Goehrig</p>
229
230 </div>
231 <h2 id="Current_Maintainers">Current Maintainers</h2>
232 <div id="Current_Maintainers_CONTENT">
233 <p>Kartik Thakore (kthakore)</p>
234 <p>Tobias Leich (FROGGS)</p>
235
236 </div>
237 <h2 id="Core_Developers_and_Contributors">Core Developers and Contributors</h2>
238 <div id="Core_Developers_and_Contributors_CON">
239 <p>The following people have dedicated blood sweat and tears to making SDL Perl possible.</p>
240 <p>See the <a href="http://github.com/kthakore/SDL_perl/graphs/impact">impact graph</a> on our github repository.</p>
241 <p>Andy Bakun &lt;sdlperl@thwartedefforts.org&gt;</p>
242 <p>Benedikt Meurer &lt;bmeurer@fwdn.de&gt;</p>
243 <p>Blaise Roth (Blaizer) &lt;blaiseroth@gmail.com&gt;</p>
244 <p>Breno G. de Oliveira (garu)</p>
245 <p>Brian Cassidy (bricas)</p>
246 <p>chromatic &lt;chromatic@wgz.org&gt;</p>
247 <p>Daniel Mantovani &lt;daniel.oliveira.mantovani@gmail.com&gt;</p>
248 <p>Daniel Ruoso http://daniel.ruoso.com/</p>
249 <p>David J. Goehrig &lt;dgoehrig@cpan.org&gt;</p>
250 <p>Dustin Mays (dorkfish) &lt;dork.fish.wat.@gmail.com&gt;</p>
251 <p>Fedora</p>
252 <p>Gabor Szabo (szabgab) &lt;szabgab@gmail.com&gt;</p>
253 <p>Guillaue Cottenceau (gc) &lt;gc@mandrakesoft.com&gt;</p>
254 <p>James King</p>
255 <p>James Wright &lt;jwright@cpan.org&gt;</p>
256 <p>Jeffrey T. Palmer (jtpalmer) &lt;jeffrey.t.palmer@gmail.com&gt;</p>
257 <p>Kartik Thakore (kthakore) &lt;thakore.kartik@gmail.com&gt;</p>
258 <p>KatrinaTheLamia</p>
259 <p>kmx &lt;kmx@cpan.org&gt;</p>
260 <p>Luke</p>
261 <p>Michael Lamertz &lt;mike@perl-ronin.de&gt;</p>
262 <p>morgoth.666</p>
263 <p>Peter BARABAS &lt;z0d@artifact.hu&gt;</p>
264 <p>Russell Valentine &lt;russ_allegro@yahoo.com&gt;</p>
265 <p>Ryan Hanlon</p>
266 <p>Stephane Desneux &lt;sdx@desneux.com&gt;</p>
267 <p>Tels &lt;http://www.bloodgate.com&gt;</p>
268 <p>Thomas Tongue</p>
269 <p>Tobias Leich (FROGGS)</p>
270 <p>Tony C</p>
271 <p>Yuval Kogman (nothingmuch)</p>
272 <p>Wayne Keenan &lt;wayne@metaverse.fsnet.co.uk&gt;</p>
273 <p>If you would like to contribute to SDL Perl, please post a message on the mailing list:</p>
274 <p>sdl-devel@perl.org</p>
275 <p>And request access to the github repository. Or drop us a line on #sdl over at irc.perl.org</p>
276
277 </div>
278 <h1 id="COPYRIGHT_amp_LICENSE">COPYRIGHT &amp; LICENSE</h1><p><a href="#TOP" class="toplink">Top</a></p>
279 <div id="COPYRIGHT_amp_LICENSE_CONTENT">
280 <p>Copyright 2002-2010 SDL Authors as listed above, all rights reserved.</p>
281 <p>This program is free software; you can redistribute it and/or modify it
282 under the same terms as Perl itself.</p>
283
284 </div>
285 <h1 id="DISCLAIMER_OF_WARRANTY">DISCLAIMER OF WARRANTY</h1><p><a href="#TOP" class="toplink">Top</a></p>
286 <div id="DISCLAIMER_OF_WARRANTY_CONTENT">
287 <p>BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
288 FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
289 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
290 PROVIDE THE SOFTWARE &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND, EITHER
291 EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
292 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
293 ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
294 YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
295 NECESSARY SERVICING, REPAIR, OR CORRECTION.</p>
296 <p>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
297 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
298 REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
299 LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
300 OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
301 THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
302 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
303 FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
304 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
305 SUCH DAMAGES.
306 </p>
307
308 </div>
309 </div>