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