Merge branch 'master' of git.shadowcat.co.uk:SDL-Site
[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>
22<li><a href="#delay">delay</a></li>
162a0989 23</ul>
24</li>
c7e8d3c6 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>
ecabf8b7 33</li>
162a0989 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">
879e3e79 39<p>SDL - Simple DirectMedia Layer for Perl</p>
162a0989 40
41</div>
05c66c33 42<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
bfdd9c2e 43<div id="CATEGORY_CONTENT">
44<p>Core</p>
45
46</div>
162a0989 47<h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
48<div id="SYNOPSIS_CONTENT">
05c66c33 49<pre> use SDL;
162a0989 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">
05c66c33 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.
57This package takes some liberties with the SDL API, and attempts to adhere to the spirit of both the SDL and Perl.
58This document describes the low-level functional SDL Perl API.
59For the object oriented programming interface please see the documentation provided on a per-class basis.</p>
162a0989 60
61</div>
05c66c33 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>
30652763 65<pre> use SDL ':all';
66
67</pre>
68<p>or access them directly:</p>
69<pre> SDL::SDL_INIT_AUDIO;
70
71</pre>
9b105a17 72<p>or by choosing the export tags below:</p>
73<p>Export tag: ':init'</p>
05c66c33 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>
801213bd 89<h2 id="init">init</h2>
90<div id="init_CONTENT">
91<pre> SDL::init( $flags );
92
93</pre>
05c66c33 94<p>As with the C language API, SDL Perl initializes the SDL environment with the <code>SDL::init</code> subroutine.
95This routine takes a mode flag constructed through the bitwise OR product of the <code>SDL_INIT_*</code> constants.
801213bd 96The <code>$flags</code> tell <code>SDL::init</code> which subsystems to initialize.</p>
05c66c33 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>
162a0989 101
102</div>
801213bd 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>.
109The <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 110<p><code>SDL::init_subsystem</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
162a0989 111
112</div>
801213bd 113<h2 id="quit_subsystem">quit_subsystem</h2>
114<div id="quit_subsystem_CONTENT">
115<pre> SDL::quit_subsystem( $flags );
116
117</pre>
05c66c33 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>.
801213bd 119The <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 120<p><code>SDL::quit_subsystem</code> doesn't return any values.</p>
162a0989 121
122</div>
801213bd 123<h2 id="quit">quit</h2>
162a0989 124<div id="quit_CONTENT">
801213bd 125<pre> SDL::quit;
126
127</pre>
05c66c33 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>
162a0989 131
132</div>
801213bd 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>
05c66c33 138<p><code>SDL::was_init</code> allows you to see which SDL subsytems have been initialized.
801213bd 139The <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 140<p><code>SDL::was_init</code> returns a mask of the initialized subsystems it checks.
801213bd 141If <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 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>
162a0989 150
162a0989 151</div>
801213bd 152<h2 id="get_error">get_error</h2>
162a0989 153<div id="get_error_CONTENT">
801213bd 154<pre> my $error = SDL::get_error;
155
156</pre>
05c66c33 157<p>Returns a scalar value containing the last error message set by the SDL library (if any).</p>
162a0989 158
159</div>
801213bd 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>
05c66c33 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>
162a0989 167
168</div>
801213bd 169<h2 id="clear_error">clear_error</h2>
096d8dc8 170<div id="clear_error_CONTENT">
801213bd 171<pre> SDL::clear_error;
172
173</pre>
05c66c33 174<p><code>SDL::clear_error</code> deletes all information about the last SDL error.
175This 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>
162a0989 177
178</div>
801213bd 179<h2 id="version">version</h2>
9b105a17 180<div id="version_CONTENT">
801213bd 181<pre> my $version = SDL::version;
182
183</pre>
05c66c33 184<p>Returns an <code>SDL::Version</code> object of the SDL library at compile-time.</p>
9b105a17 185<pre> use SDL;
186 use SDL::Version;
187
801213bd 188 my $v = SDL::version;
9b105a17 189 printf(&quot;got version: %d.%d.%d\n&quot;, $v-&gt;major, $v-&gt;minor, $v-&gt;patch);
162a0989 190
9b105a17 191</pre>
162a0989 192
193</div>
801213bd 194<h2 id="linked_version">linked_version</h2>
162a0989 195<div id="linked_version_CONTENT">
05c66c33 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>
162a0989 197
198</div>
801213bd 199<h2 id="get_ticks">get_ticks</h2>
05c66c33 200<div id="get_ticks_CONTENT">
801213bd 201<pre> my $ticks = SDL::get_ticks;
202
203</pre>
05c66c33 204<p>Returns the number of milliseconds since SDL library initialization.
205This value wraps around if the program runs for more than 49.7 days</p>
162a0989 206
207</div>
801213bd 208<h2 id="delay">delay</h2>
209<div id="delay_CONTENT">
210<pre> SDL::delay( $ms );
211
212</pre>
05c66c33 213<p><code>SDL::delay</code> waits the specified number of milliseconds before returning.
214The 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);
9b105a17 218
219</pre>
162a0989 220
ecabf8b7 221</div>
c7e8d3c6 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>
4769fd12 243<p>Blaise Roth (Blaizer) &lt;blaizer@cpan.org&gt;</p>
c7e8d3c6 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>Heikki Meht&195;nen (hmehta/hejki) &lt;heikki@mehtanen.fi&gt;</p>
255<p>James King</p>
256<p>James Wright &lt;jwright@cpan.org&gt;</p>
257<p>Jeffrey T. Palmer (jtpalmer) &lt;jeffrey.t.palmer@gmail.com&gt;</p>
258<p>Kartik Thakore (kthakore) &lt;thakore.kartik@gmail.com&gt;</p>
259<p>KatrinaTheLamia</p>
260<p>kmx &lt;kmx@cpan.org&gt;</p>
261<p>Luke</p>
262<p>Michael Lamertz &lt;mike@perl-ronin.de&gt;</p>
263<p>morgoth.666</p>
264<p>Peter BARABAS &lt;z0d@artifact.hu&gt;</p>
265<p>Russell Valentine &lt;russ_allegro@yahoo.com&gt;</p>
266<p>Ryan Hanlon</p>
267<p>Stephane Desneux &lt;sdx@desneux.com&gt;</p>
268<p>Tels &lt;http://www.bloodgate.com&gt;</p>
269<p>Thomas Tongue</p>
270<p>Tobias Leich (FROGGS)</p>
271<p>Tony C</p>
272<p>Yuval Kogman (nothingmuch)</p>
273<p>Wayne Keenan &lt;wayne@metaverse.fsnet.co.uk&gt;</p>
274<p>If you would like to contribute to SDL Perl, please post a message on the mailing list:</p>
275<p>sdl-devel@perl.org</p>
276<p>And request access to the github repository. Or drop us a line on #sdl over at irc.perl.org</p>
277
278</div>
279<h1 id="COPYRIGHT_amp_LICENSE">COPYRIGHT &amp; LICENSE</h1><p><a href="#TOP" class="toplink">Top</a></p>
280<div id="COPYRIGHT_amp_LICENSE_CONTENT">
281<p>Copyright 2002-2010 SDL Authors as listed above, all rights reserved.</p>
282<p>This program is free software; you can redistribute it and/or modify it
283under the same terms as Perl itself.</p>
284
285</div>
286<h1 id="DISCLAIMER_OF_WARRANTY">DISCLAIMER OF WARRANTY</h1><p><a href="#TOP" class="toplink">Top</a></p>
287<div id="DISCLAIMER_OF_WARRANTY_CONTENT">
288<p>BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
289FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
290OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
291PROVIDE THE SOFTWARE &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND, EITHER
292EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
293WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
294ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
295YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
296NECESSARY SERVICING, REPAIR, OR CORRECTION.</p>
297<p>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
298WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
299REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
300LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
301OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
302THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
303RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
304FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
305SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
306SUCH DAMAGES.
307</p>
162a0989 308
309</div>
310</div>