3 <h3 id="TOP">Index</h3>
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>
25 <li><a href="#AUTHOR">AUTHOR</a>
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>
35 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
36 <div id="CATEGORY_CONTENT">
40 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
41 <div id="SYNOPSIS_CONTENT">
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>
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>
61 <p>or access them directly:</p>
62 <pre> SDL::SDL_INIT_AUDIO;
65 <p>or by choosing the export tags below:</p>
66 <p>Export tag: ':init'</p>
78 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
79 <div id="METHODS_CONTENT">
82 <h2 id="init">init</h2>
83 <div id="init_CONTENT">
84 <pre> SDL::init( $flags );
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);
93 <p><code>SDL::init</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
96 <h2 id="init_subsystem">init_subsystem</h2>
97 <div id="init_subsystem_CONTENT">
98 <pre> SDL::init_subsystem( $flags );
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>
106 <h2 id="quit_subsystem">quit_subsystem</h2>
107 <div id="quit_subsystem_CONTENT">
108 <pre> SDL::quit_subsystem( $flags );
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>
116 <h2 id="quit">quit</h2>
117 <div id="quit_CONTENT">
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>
126 <h2 id="was_init">was_init</h2>
127 <div id="was_init_CONTENT">
128 <pre> my $flags = SDL::was_init( $flags );
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';
137 my $mask = SDL::was_init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
138 if($mask & SDL_INIT_AUDIO and $mask & SDL_INIT_JOYSTICK) {
139 # Both subsystems are initialized!
145 <h2 id="get_error">get_error</h2>
146 <div id="get_error_CONTENT">
147 <pre> my $error = SDL::get_error;
150 <p>Returns a scalar value containing the last error message set by the SDL library (if any).</p>
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 )
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>
162 <h2 id="clear_error">clear_error</h2>
163 <div id="clear_error_CONTENT">
164 <pre> SDL::clear_error;
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>
172 <h2 id="version">version</h2>
173 <div id="version_CONTENT">
174 <pre> my $version = SDL::version;
177 <p>Returns an <code>SDL::Version</code> object of the SDL library at compile-time.</p>
181 my $v = SDL::version;
182 printf("got version: %d.%d.%d\n", $v->major, $v->minor, $v->patch);
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>
192 <h2 id="get_ticks">get_ticks</h2>
193 <div id="get_ticks_CONTENT">
194 <pre> my $ticks = SDL::get_ticks;
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>
201 <h2 id="delay">delay</h2>
202 <div id="delay_CONTENT">
203 <pre> SDL::delay( $ms );
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
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>