99b926e7a7586f0c66836895d286273919b6e0b1
[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>
6 <ul><li><a href="#CATEGORY">CATEGORY</a></li>
7 </ul>
8 </li>
9 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
10 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
11 <li><a href="#Functions_exported_by_SDL_pm">Functions exported by SDL.pm</a>
12 <ul><li><a href="#init_flags">init(flags) </a></li>
13 <li><a href="#init_subsystem_flags">init_subsystem(flags)</a></li>
14 <li><a href="#quit_subsystem_flags">quit_subsystem(flags)</a></li>
15 <li><a href="#quit">quit</a></li>
16 <li><a href="#was_init_flags">was_init(flags)</a></li>
17 <li><a href="#get_error">get_error()</a></li>
18 <li><a href="#set_error_real_error_values">set_error_real(error, @values)</a></li>
19 <li><a href="#clear_error">clear_error()</a></li>
20 <li><a href="#version">version()</a></li>
21 <li><a href="#linked_version">linked_version</a></li>
22 <li><a href="#get_error-2">get_error()</a></li>
23 <li><a href="#delay_ms">delay(ms)</a></li>
24 </ul>
25 </li>
26 <li><a href="#AUTHORS">AUTHORS</a>
27 </li>
28 </ul><hr />
29 <!-- INDEX END -->
30
31 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
32 <div id="NAME_CONTENT">
33 <p>SDL - Simple DirectMedia Layer for Perl</p>
34
35 </div>
36 <h2 id="CATEGORY">CATEGORY</h2>
37 <div id="CATEGORY_CONTENT">
38 <p>Core</p>
39
40 </div>
41 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
42 <div id="SYNOPSIS_CONTENT">
43 <pre>  use SDL ':all';
44
45 </pre>
46
47 </div>
48 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
49 <div id="DESCRIPTION_CONTENT">
50 <p>SDL_perl is a package of perl modules that provides both functional and object orient
51 interfaces to the Simple DirectMedia Layer for Perl 5.  This package does take some
52 liberties with the SDL API, and attempts to adhere to the spirit of both the SDL
53 and Perl.  This document describes the low-level functional SDL_perl API.  For the
54 object oriented programming interface please see the documentation provided on a
55 per class basis.</p>
56
57 </div>
58 <h1 id="Functions_exported_by_SDL_pm">Functions exported by SDL.pm</h1><p><a href="#TOP" class="toplink">Top</a></p>
59 <div id="Functions_exported_by_SDL_pm_CONTENT">
60
61 </div>
62 <h2 id="init_flags">init(flags) </h2>
63 <div id="init_flags_CONTENT">
64 <p>As with the C language API, SDL_perl initializes the SDL environment through
65 the <code>SDL::init</code> subroutine. This routine takes a mode flag constructed through
66 the bitwise OR product of the SDL_INIT_* constants.</p>
67 <p>The constants are not exported by default. You can export them into your namespace by doing:</p>
68 <pre> use SDL ':all';
69
70 </pre>
71 <p>or access them directly:</p>
72 <pre> SDL::SDL_INIT_AUDIO;
73
74 </pre>
75 <p>or by choosing the export tags below:</p>
76 <p>Export tag: ':init'</p>
77 <dl>
78         <dt>*
79 SDL_INIT_AUDIO</dt>
80         <dt>*
81 SDL_INIT_VIDEO</dt>
82         <dt>*
83 SDL_INIT_CDROM</dt>
84         <dt>*
85 SDL_INIT_EVERYTHING</dt>
86         <dt>*
87 SDL_INIT_NOPARACHUTE</dt>
88         <dt>*
89 SDL_INIT_JOYSTICK</dt>
90         <dt>*
91 SDL_INIT_TIMER</dt>
92 </dl>
93 <p><code>SDL::Init</code> returns 0 on success, or -1 on error.</p>
94
95 </div>
96 <h2 id="init_subsystem_flags">init_subsystem(flags)</h2>
97 <div id="init_subsystem_flags_CONTENT">
98 <p>After SDL has been initialized with SDL::init you may initialize uninitialized subsystems with SDL::init_subsystem.
99 The flags parameter is the same as that used in SDL::init. </p>
100 <p>SDL::init_subsystem returns 0 on success, or -1 on error.</p>
101
102 </div>
103 <h2 id="quit_subsystem_flags">quit_subsystem(flags)</h2>
104 <div id="quit_subsystem_flags_CONTENT">
105 <p>SDL::quit_subsystem allows you to shut down a subsystem that has been previously initialized by SDL::init or SDL::init_subsystem.
106 The flags tells SDL::quit_subSystem which subsystems to shut down, it uses the same values that are passed to SDL::init. </p>
107 <p>SDL::quit_subsystem doesn't returns any value.</p>
108
109 </div>
110 <h2 id="quit">quit</h2>
111 <div id="quit_CONTENT">
112 <p>Shuts down all SDL subsystems, unloads the dynamically linked library and frees the allocated resources.</p>
113 <p><strong>Note</strong>: This will be called automatically when perl exits. You don't need to call this, except you want to initialize SDL after this again.</p>
114 <p>SDL::quit doesn't returns any value.</p>
115
116 </div>
117 <h2 id="was_init_flags">was_init(flags)</h2>
118 <div id="was_init_flags_CONTENT">
119 <p>SDL::was_init allows you to see which SDL subsytems have been initialized.
120 flags is a bitwise OR'd combination of the subsystems you wish to check (see SDL::init for a list of subsystem flags). 
121 If 'flags' is 0 or SDL_INIT_EVERYTHING, it returns a mask of all initialized subsystems (this does not include SDL_INIT_EVENTTHREAD or SDL_INIT_NOPARACHUTE).</p>
122
123 </div>
124 <h2 id="get_error">get_error()</h2>
125 <div id="get_error_CONTENT">
126 <p>The last error message set by the SDL library can be retrieved using the subroutine
127 <code>SDL::get_error</code>, which returns a scalar containing the text of the message if any.</p>
128
129 </div>
130 <h2 id="set_error_real_error_values">set_error_real(error, @values)</h2>
131 <div id="set_error_real_error_values_CONTENT">
132 <p>SDL::set_error_real sets the SDL error to a printf style formatted string. 
133 it doesn't returns any values.</p>
134
135 </div>
136 <h2 id="clear_error">clear_error()</h2>
137 <div id="clear_error_CONTENT">
138 <p>SDL::clear_error deletes all information about the last SDL error. Useful if the error has been handled by the program.
139 it doesn't returns any value.</p>
140
141 </div>
142 <h2 id="version">version()</h2>
143 <div id="version_CONTENT">
144 <pre> my $version = SDL::version();
145
146 </pre>
147 <p>Returns an SDL::Version object of the of the SDL library at compile time.</p>
148 <p>Example:</p>
149 <pre> use SDL;
150  use SDL::Version;
151
152  my $v = SDL::version();
153  printf(&quot;got version: %d.%d.%d\n&quot;, $v-&gt;major, $v-&gt;minor, $v-&gt;patch);
154
155
156
157
158 </pre>
159
160 </div>
161 <h2 id="linked_version">linked_version</h2>
162 <div id="linked_version_CONTENT">
163 <pre> my $linked_version = SDL::linked_version();
164
165 </pre>
166 <p>Returns an SDL::Version object of the currently loaded SDL library.</p>
167 <p>Example:</p>
168 <pre> use SDL;
169  use SDL::Version;
170
171  my $v = SDL::linked_version();
172  printf(&quot;got version: %d.%d.%d\n&quot;, $v-&gt;major, $v-&gt;minor, $v-&gt;patch);
173
174 </pre>
175
176 </div>
177 <h2 id="get_error-2">get_error()</h2>
178 <div id="get_error_CONTENT-2">
179 <p>The last error message set by the SDL library can be retrieved using the subroutine
180 <code>SDL::get_error</code>, which returns a scalar containing the text of the message if any.</p>
181
182 </div>
183 <h2 id="delay_ms">delay(ms)</h2>
184 <div id="delay_ms_CONTENT">
185 <pre> SDL::delay(1000);
186
187 </pre>
188 <p>This subroutine allows an application to delay further operations for atleast a
189 number of milliseconds provided as the argument.  The actual delay may be longer
190 than the specified depending on the underlying OS.</p>
191
192 </div>
193 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
194 <div id="AUTHORS_CONTENT">
195 <p>magnet, kthakore
196 </p>
197
198 </div>
199 </div>