Updatedd pods
[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_flags">init(flags)</a></li>
12 <li><a href="#init_subsystem_flags">init_subsystem(flags)</a></li>
13 <li><a href="#quit_subsystem_flags">quit_subsystem(flags)</a></li>
14 <li><a href="#quit">quit()</a></li>
15 <li><a href="#was_init_flags">was_init(flags)</a></li>
16 <li><a href="#get_error">get_error()</a></li>
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>
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_ms">delay(ms)</a></li>
23 </ul>
24 </li>
25 <li><a href="#AUTHORS">AUTHORS</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_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.
85 This routine takes a mode flag constructed through the bitwise OR product of the <code>SDL_INIT_*</code> constants.
86 The <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>
91
92 </div>
93 <h2 id="init_subsystem_flags">init_subsystem(flags)</h2>
94 <div id="init_subsystem_flags_CONTENT">
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>.
96 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>
97 <p><code>SDL::init_subsystem</code> returns <code>0</code> on success, or <code>-1</code> on error.</p>
98
99 </div>
100 <h2 id="quit_subsystem_flags">quit_subsystem(flags)</h2>
101 <div id="quit_subsystem_flags_CONTENT">
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>.
103 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>
104 <p><code>SDL::quit_subsystem</code> doesn't return any values.</p>
105
106 </div>
107 <h2 id="quit">quit()</h2>
108 <div id="quit_CONTENT">
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>
112
113 </div>
114 <h2 id="was_init_flags">was_init(flags)</h2>
115 <div id="was_init_flags_CONTENT">
116 <p><code>SDL::was_init</code> allows you to see which SDL subsytems have been initialized.
117 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>
118 <p><code>SDL::was_init</code> returns a mask of the initialized subsystems it checks.
119 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>
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>
128
129 </div>
130 <h2 id="get_error">get_error()</h2>
131 <div id="get_error_CONTENT">
132 <p>Returns a scalar value containing the last error message set by the SDL library (if any).</p>
133
134 </div>
135 <h2 id="set_error_real_error_values">set_error_real(error, @values)</h2>
136 <div id="set_error_real_error_values_CONTENT">
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>
139
140 </div>
141 <h2 id="clear_error">clear_error()</h2>
142 <div id="clear_error_CONTENT">
143 <p><code>SDL::clear_error</code> deletes all information about the last SDL error.
144 This 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>
146
147 </div>
148 <h2 id="version">version()</h2>
149 <div id="version_CONTENT">
150 <p>Returns an <code>SDL::Version</code> object of the SDL library at compile-time.</p>
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);
156
157 </pre>
158
159 </div>
160 <h2 id="linked_version">linked_version()</h2>
161 <div id="linked_version_CONTENT">
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>
163
164 </div>
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.
168 This value wraps around if the program runs for more than 49.7 days</p>
169
170 </div>
171 <h2 id="delay_ms">delay(ms)</h2>
172 <div id="delay_ms_CONTENT">
173 <p><code>SDL::delay</code> waits the specified number of milliseconds before returning.
174 The 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);
178
179 </pre>
180
181 </div>
182 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
183 <div id="AUTHORS_CONTENT">
184 <p>magnet, kthakore, Blaizer</p>
185
186 </div>
187 </div>