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="#AUTHOR">AUTHOR</a>
26 </li>
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">
32 <p>SDL - Simple DirectMedia Layer for Perl</p>
33
34 </div>
35 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
36 <div id="CATEGORY_CONTENT">
37 <p>Core</p>
38
39 </div>
40 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
41 <div id="SYNOPSIS_CONTENT">
42 <pre> use SDL;
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">
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.
50 This package takes some liberties with the SDL API, and attempts to adhere to the spirit of both the SDL and Perl.
51 This document describes the low-level functional SDL Perl API.
52 For the object oriented programming interface please see the documentation provided on a per-class basis.</p>
53
54 </div>
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>
58 <pre> use SDL ':all';
59
60 </pre>
61 <p>or access them directly:</p>
62 <pre> SDL::SDL_INIT_AUDIO;
63
64 </pre>
65 <p>or by choosing the export tags below:</p>
66 <p>Export tag: ':init'</p>
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">init</h2>
83 <div id="init_CONTENT">
84 <pre> SDL::init( $flags );
85
86 </pre>
87 <p>As with the C language API, SDL Perl initializes the SDL environment with the <code>SDL::init</code> subroutine.
88 This routine takes a mode flag constructed through the bitwise OR product of the <code>SDL_INIT_*</code> constants.
89 The <code>$flags</code> tell <code>SDL::init</code> which subsystems to initialize.</p>
90 <pre> SDL::init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
91
92 </pre>
93 <p><code>SDL::init</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
94
95 </div>
96 <h2 id="init_subsystem">init_subsystem</h2>
97 <div id="init_subsystem_CONTENT">
98 <pre> SDL::init_subsystem( $flags );
99
100 </pre>
101 <p>After SDL has been initialized with <code>SDL::init</code> you may initialize any uninitialized subsystems with <code>SDL::init_subsystem</code>.
102 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>
103 <p><code>SDL::init_subsystem</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
104
105 </div>
106 <h2 id="quit_subsystem">quit_subsystem</h2>
107 <div id="quit_subsystem_CONTENT">
108 <pre> SDL::quit_subsystem( $flags );
109
110 </pre>
111 <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>.
112 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>
113 <p><code>SDL::quit_subsystem</code> doesn't return any values.</p>
114
115 </div>
116 <h2 id="quit">quit</h2>
117 <div id="quit_CONTENT">
118 <pre> SDL::quit;
119
120 </pre>
121 <p><code>SDL::quit</code> Shuts down all SDL subsystems, unloads the dynamically linked library and frees the allocated resources.</p>
122 <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>
123 <p><code>SDL::quit</code> doesn't return any values.</p>
124
125 </div>
126 <h2 id="was_init">was_init</h2>
127 <div id="was_init_CONTENT">
128 <pre> my $flags = SDL::was_init( $flags );
129
130 </pre>
131 <p><code>SDL::was_init</code> allows you to see which SDL subsytems have been initialized.
132 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>
133 <p><code>SDL::was_init</code> returns a mask of the initialized subsystems it checks.
134 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>
135 <pre> use SDL ':all';
136
137  my $mask = SDL::was_init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
138  if($mask &amp; SDL_INIT_AUDIO and $mask &amp; SDL_INIT_JOYSTICK) {
139      # Both subsystems are initialized!
140  }
141
142 </pre>
143
144 </div>
145 <h2 id="get_error">get_error</h2>
146 <div id="get_error_CONTENT">
147 <pre> my $error = SDL::get_error;
148
149 </pre>
150 <p>Returns a scalar value containing the last error message set by the SDL library (if any).</p>
151
152 </div>
153 <h2 id="set_error_real">set_error_real</h2>
154 <div id="set_error_real_CONTENT">
155 <pre> SDL::set_error_real( $printf_format, @values )
156
157 </pre>
158 <p><code>SDL::set_error_real</code> sets the SDL error to a <code>printf</code> style formatted string.</p>
159 <p><code>SDL::set_error_real</code> doesn't return any values.</p>
160
161 </div>
162 <h2 id="clear_error">clear_error</h2>
163 <div id="clear_error_CONTENT">
164 <pre> SDL::clear_error;
165
166 </pre>
167 <p><code>SDL::clear_error</code> deletes all information about the last SDL error.
168 This is useful if the error has been handled by the program.</p>
169 <p><code>SDL::clear_error</code> doesn't return any values.</p>
170
171 </div>
172 <h2 id="version">version</h2>
173 <div id="version_CONTENT">
174 <pre> my $version = SDL::version;
175
176 </pre>
177 <p>Returns an <code>SDL::Version</code> object of the SDL library at compile-time.</p>
178 <pre> use SDL;
179  use SDL::Version;
180
181  my $v = SDL::version;
182  printf(&quot;got version: %d.%d.%d\n&quot;, $v-&gt;major, $v-&gt;minor, $v-&gt;patch);
183
184 </pre>
185
186 </div>
187 <h2 id="linked_version">linked_version</h2>
188 <div id="linked_version_CONTENT">
189 <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>
190
191 </div>
192 <h2 id="get_ticks">get_ticks</h2>
193 <div id="get_ticks_CONTENT">
194 <pre> my $ticks = SDL::get_ticks;
195
196 </pre>
197 <p>Returns the number of milliseconds since SDL library initialization.
198 This value wraps around if the program runs for more than 49.7 days</p>
199
200 </div>
201 <h2 id="delay">delay</h2>
202 <div id="delay_CONTENT">
203 <pre> SDL::delay( $ms );
204
205 </pre>
206 <p><code>SDL::delay</code> waits the specified number of milliseconds before returning.
207 The actual delay may be longer than specified depending on the underlying OS.</p>
208 <p><code>SDL::delay</code> doesn't return anything.</p>
209 <pre> # Delay for half a second
210  SDL::delay(500);
211
212 </pre>
213
214 </div>
215 <h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
216 <div id="AUTHOR_CONTENT">
217 <p>magnet, kthakore, Blaizer</p>
218
219 </div>
220 </div>