Updatedd pods
[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>
11<ul><li><a href="#init_flags">init(flags)</a></li>
162a0989 12<li><a href="#init_subsystem_flags">init_subsystem(flags)</a></li>
13<li><a href="#quit_subsystem_flags">quit_subsystem(flags)</a></li>
05c66c33 14<li><a href="#quit">quit()</a></li>
162a0989 15<li><a href="#was_init_flags">was_init(flags)</a></li>
16<li><a href="#get_error">get_error()</a></li>
9b105a17 17<li><a href="#set_error_real_error_values">set_error_real(error, @values)</a></li>
18<li><a href="#clear_error">clear_error()</a></li>
162a0989 19<li><a href="#version">version()</a></li>
05c66c33 20<li><a href="#linked_version">linked_version()</a></li>
21<li><a href="#get_ticks">get_ticks()</a></li>
ecabf8b7 22<li><a href="#delay_ms">delay(ms)</a></li>
162a0989 23</ul>
24</li>
096d8dc8 25<li><a href="#AUTHORS">AUTHORS</a>
ecabf8b7 26</li>
162a0989 27</ul><hr />
28<!-- INDEX END -->
29
30<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
31<div id="NAME_CONTENT">
879e3e79 32<p>SDL - Simple DirectMedia Layer for Perl</p>
162a0989 33
34</div>
05c66c33 35<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
bfdd9c2e 36<div id="CATEGORY_CONTENT">
37<p>Core</p>
38
39</div>
162a0989 40<h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
41<div id="SYNOPSIS_CONTENT">
05c66c33 42<pre> use SDL;
162a0989 43
44</pre>
45
46</div>
47<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
48<div id="DESCRIPTION_CONTENT">
05c66c33 49<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.
50This package takes some liberties with the SDL API, and attempts to adhere to the spirit of both the SDL and Perl.
51This document describes the low-level functional SDL Perl API.
52For the object oriented programming interface please see the documentation provided on a per-class basis.</p>
162a0989 53
54</div>
05c66c33 55<h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
56<div id="CONSTANTS_CONTENT">
57<p>The constants are not exported by default. You can export them by doing:</p>
30652763 58<pre> use SDL ':all';
59
60</pre>
61<p>or access them directly:</p>
62<pre> SDL::SDL_INIT_AUDIO;
63
64</pre>
9b105a17 65<p>or by choosing the export tags below:</p>
66<p>Export tag: ':init'</p>
05c66c33 67<pre> SDL_INIT_AUDIO
68 SDL_INIT_VIDEO
69 SDL_INIT_CDROM
70 SDL_INIT_EVERYTHING
71 SDL_INIT_NOPARACHUTE
72 SDL_INIT_JOYSTICK
73 SDL_INIT_TIMER
74
75</pre>
76
77</div>
78<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
79<div id="METHODS_CONTENT">
80
81</div>
82<h2 id="init_flags">init(flags)</h2>
83<div id="init_flags_CONTENT">
84<p>As with the C language API, SDL Perl initializes the SDL environment with the <code>SDL::init</code> subroutine.
85This routine takes a mode flag constructed through the bitwise OR product of the <code>SDL_INIT_*</code> constants.
86The <code>flags</code> tell <code>SDL::init</code> which subsystems to initialize.</p>
87<pre> SDL::init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
88
89</pre>
90<p><code>SDL::init</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
162a0989 91
92</div>
93<h2 id="init_subsystem_flags">init_subsystem(flags)</h2>
94<div id="init_subsystem_flags_CONTENT">
05c66c33 95<p>After <code>SDL</code> has been initialized with <code>SDL::init</code> you may initialize any uninitialized subsystems with <code>SDL::init_subsystem</code>.
96The <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>
97<p><code>SDL::init_subsystem</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
162a0989 98
99</div>
100<h2 id="quit_subsystem_flags">quit_subsystem(flags)</h2>
101<div id="quit_subsystem_flags_CONTENT">
05c66c33 102<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>.
103The <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>
104<p><code>SDL::quit_subsystem</code> doesn't return any values.</p>
162a0989 105
106</div>
05c66c33 107<h2 id="quit">quit()</h2>
162a0989 108<div id="quit_CONTENT">
05c66c33 109<p><code>SDL::quit</code> Shuts down all SDL subsystems, unloads the dynamically linked library and frees the allocated resources.</p>
110<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>
111<p><code>SDL::quit</code> doesn't return any values.</p>
162a0989 112
113</div>
114<h2 id="was_init_flags">was_init(flags)</h2>
115<div id="was_init_flags_CONTENT">
05c66c33 116<p><code>SDL::was_init</code> allows you to see which SDL subsytems have been initialized.
117The <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>
118<p><code>SDL::was_init</code> returns a mask of the initialized subsystems it checks.
119If <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>
120<pre> use SDL ':all';
121
122 my $mask = SDL::was_init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
123 if($mask &amp; SDL_INIT_AUDIO and $mask &amp; SDL_INIT_JOYSTICK) {
124 # Both subsystems are initialized!
125 }
126
127</pre>
162a0989 128
162a0989 129</div>
130<h2 id="get_error">get_error()</h2>
131<div id="get_error_CONTENT">
05c66c33 132<p>Returns a scalar value containing the last error message set by the SDL library (if any).</p>
162a0989 133
134</div>
9b105a17 135<h2 id="set_error_real_error_values">set_error_real(error, @values)</h2>
096d8dc8 136<div id="set_error_real_error_values_CONTENT">
05c66c33 137<p><code>SDL::set_error_real</code> sets the SDL error to a <code>printf</code> style formatted string.</p>
138<p><code>SDL::set_error_real</code> doesn't return any values.</p>
162a0989 139
140</div>
9b105a17 141<h2 id="clear_error">clear_error()</h2>
096d8dc8 142<div id="clear_error_CONTENT">
05c66c33 143<p><code>SDL::clear_error</code> deletes all information about the last SDL error.
144This is useful if the error has been handled by the program.</p>
145<p><code>SDL::clear_error</code> doesn't return any values.</p>
162a0989 146
147</div>
9b105a17 148<h2 id="version">version()</h2>
149<div id="version_CONTENT">
05c66c33 150<p>Returns an <code>SDL::Version</code> object of the SDL library at compile-time.</p>
9b105a17 151<pre> use SDL;
152 use SDL::Version;
153
154 my $v = SDL::version();
155 printf(&quot;got version: %d.%d.%d\n&quot;, $v-&gt;major, $v-&gt;minor, $v-&gt;patch);
162a0989 156
9b105a17 157</pre>
162a0989 158
159</div>
05c66c33 160<h2 id="linked_version">linked_version()</h2>
162a0989 161<div id="linked_version_CONTENT">
05c66c33 162<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 163
164</div>
05c66c33 165<h2 id="get_ticks">get_ticks()</h2>
166<div id="get_ticks_CONTENT">
167<p>Returns the number of milliseconds since SDL library initialization.
168This value wraps around if the program runs for more than 49.7 days</p>
162a0989 169
170</div>
171<h2 id="delay_ms">delay(ms)</h2>
172<div id="delay_ms_CONTENT">
05c66c33 173<p><code>SDL::delay</code> waits the specified number of milliseconds before returning.
174The actual delay may be longer than specified depending on the underlying OS.</p>
175<p><code>SDL::delay</code> doesn't return anything.</p>
176<pre> # Delay for half a second
177 SDL::delay(500);
9b105a17 178
179</pre>
162a0989 180
ecabf8b7 181</div>
096d8dc8 182<h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
183<div id="AUTHORS_CONTENT">
05c66c33 184<p>magnet, kthakore, Blaizer</p>
162a0989 185
186</div>
187</div>