File: CastleALUtils.html

package info (click to toggle)
castle-game-engine 5.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 185,428 kB
  • sloc: pascal: 260,781; cpp: 1,363; objc: 713; makefile: 537; xml: 496; sh: 480; php: 4
file content (350 lines) | stat: -rw-r--r-- 18,219 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Castle Game Engine: CastleALUtils</title>
<meta name="generator" content="PasDoc 0.13.0">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="StyleSheet" type="text/css" href="pasdoc.css">
</head>
<body>
<table class="container"><tr><td class="navigation">
<h2>Castle Game Engine</h2><p><a href="introduction.html" class="navigation">Introduction</a></p><p><a href="AllUnits.html" class="navigation">Units</a></p><p><a href="ClassHierarchy.html" class="navigation">Class Hierarchy</a></p><p><a href="AllClasses.html" class="navigation">Classes, Interfaces, Objects and Records</a></p><p><a href="AllTypes.html" class="navigation">Types</a></p><p><a href="AllVariables.html" class="navigation">Variables</a></p><p><a href="AllConstants.html" class="navigation">Constants</a></p><p><a href="AllFunctions.html" class="navigation">Functions and Procedures</a></p><p><a href="AllIdentifiers.html" class="navigation">Identifiers</a></p></td><td class="content">
<h1 class="unit">Unit CastleALUtils</h1>
<table class="sections wide_list">
<tr>
<td><a class="section" href="#PasDoc-Description">Description</a></td><td><a class="section" href="#PasDoc-Uses">Uses</a></td><td><a class="section" href="#PasDoc-Classes">Classes, Interfaces, Objects and Records</a></td><td><a class="section" href="#PasDoc-FuncsProcs">Functions and Procedures</a></td><td>Types</td><td><a class="section" href="#PasDoc-Constants">Constants</a></td><td>Variables</td></tr></table>
<a name="PasDoc-Description"></a><h2 class="description">Description</h2>
<p>
Low-level utilities for working with OpenAL. Everything is based on my OpenAL bindings in unit CastleOpenAL. For higher-level class that takes care of initializing OpenAL and loading and playing sounds, see <a class="normal" href="CastleSoundEngine.html">CastleSoundEngine</a>.

<p>You shouldn't use any alc* functions or alutInit/alutExit functions from CastleOpenAL yourself. This unit and <a class="normal" href="CastleSoundEngine.html">CastleSoundEngine</a> take care about everything needed there.</p>
<a name="PasDoc-Uses"></a><h2 class="uses">Uses</h2>
<ul class="useslist"><li>SysUtils</li><li><a  href="CastleUtils.html">CastleUtils</a></li><li>CastleOpenAL</li><li>Classes</li><li><a  href="CastleSoundFile.html">CastleSoundFile</a></li><li><a  href="CastleTimeUtils.html">CastleTimeUtils</a></li></ul><h2 class="overview">Overview</h2>
<a name="PasDoc-Classes"></a><h3 class="cio">Classes, Interfaces, Objects and Records</h3>
<table class="classestable wide_list">
<tr class="listheader">
<th class="itemname">Name</th>
<th class="itemdesc">Description</th>
</tr>
<tr class="list">
<td class="itemname">Class&nbsp;<a class="bold" href="CastleALUtils.EOpenALError.html"><code>EOpenALError</code></a></td>
<td class="itemdesc">&nbsp;</td>
</tr>
<tr class="list2">
<td class="itemname">Class&nbsp;<a class="bold" href="CastleALUtils.EOpenALInitError.html"><code>EOpenALInitError</code></a></td>
<td class="itemdesc">&nbsp;</td>
</tr>
<tr class="list">
<td class="itemname">Class&nbsp;<a class="bold" href="CastleALUtils.EALError.html"><code>EALError</code></a></td>
<td class="itemdesc">Exception for errors reported by alGetError (using constants AL_xxx).</td>
</tr>
<tr class="list2">
<td class="itemname">Class&nbsp;<a class="bold" href="CastleALUtils.TALSoundFile.html"><code>TALSoundFile</code></a></td>
<td class="itemdesc">&nbsp;</td>
</tr>
</table>
<a name="PasDoc-FuncsProcs"></a><h3 class="summary">Functions and Procedures</h3>
<table class="summary wide_list">
<tr class="list">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#CheckALInited">CheckALInited</a></b>;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#CheckAL">CheckAL</a></b>(const situation: string);</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetSource1i">alGetSource1i</a></b>(SourceName: TALuint; Attribute: TALenum): TALint;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetSource1f">alGetSource1f</a></b>(SourceName: TALuint; Attribute: TALenum): TALfloat;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetSource1bool">alGetSource1bool</a></b>(SourceName: TALuint; Attribute: TALenum): TALboolean;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetSource1ui">alGetSource1ui</a></b>(SourceName: TALuint; Attribute: TALenum): TALuint;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetSource3f">alGetSource3f</a></b>(SourceName: TALuint; Attribute: TALenum): TALVector3f;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetBuffer1sizei">alGetBuffer1sizei</a></b>(BufferName: TALuint; Attribute: TALenum): TALsizei;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetBuffer1i">alGetBuffer1i</a></b>(BufferName: TALuint; Attribute: TALenum): TALint;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetBuffer1f">alGetBuffer1f</a></b>(BufferName: TALuint; Attribute: TALenum): TALfloat;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetListener1f">alGetListener1f</a></b>(Attribute: TALenum): TALfloat;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetListener3f">alGetListener3f</a></b>(Attribute: TALenum): TALVector3f;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alGetListenerOrientation">alGetListenerOrientation</a></b>: TALTwoVectors3f;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a  href="CastleALUtils.html#alcGetInterger1">alcGetInterger1</a></b>(deviceHandle:PALCdevice; token:TALenum): TALint;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#alSourceVector3f">alSourceVector3f</a></b>(SourceName: TALuint; Param: TALenum; const Value: TALVector3f);</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#alListenerVector3f">alListenerVector3f</a></b>(Param: TALenum; const Value: TALVector3f);</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#alListenerOrientation">alListenerOrientation</a></b>(const Dir, Up: TALVector3f); overload;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#alListenerOrientation">alListenerOrientation</a></b>(const Orient: TALTwoVectors3f); overload;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#alCreateSources">alCreateSources</a></b>(n: TALsizei; sources: PALuint);</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#alCreateBuffers">alCreateBuffers</a></b>(n: TALsizei; buffers: PALuint);</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#alFreeSource">alFreeSource</a></b>(var Source: TALuint);</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>procedure <b><a  href="CastleALUtils.html#alFreeBuffer">alFreeBuffer</a></b>(var Buffer: TALuint);</code></td>
</tr>
</table>
<a name="PasDoc-Constants"></a><h3 class="summary">Constants</h3>
<table class="summary wide_list">
<tr class="list">
<td class="itemcode"><code><b><a  href="CastleALUtils.html#BoolToAL">BoolToAL</a></b>: array[boolean] of TALint = (AL_FALSE, AL_TRUE);</code></td>
</tr>
</table>
<h2 class="description">Description</h2>
<h3 class="detail">Functions and Procedures</h3>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="CheckALInited"></a><code>procedure <b>CheckALInited</b>;</code></td>
</tr>
<tr><td colspan="1">
<p>
Check is ALInited <code>True</code>. </p>
<h6 class="description_section">Exceptions raised</h6>
<dl class="exceptions_raised">
<dt><a class="normal" href="CastleALUtils.EOpenALInitError.html">EOpenALInitError</a></dt>
<dd>If ALInited is <code>False</code>.</dd>
</dl>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="CheckAL"></a><code>procedure <b>CheckAL</b>(const situation: string);</code></td>
</tr>
<tr><td colspan="1">
&nbsp;<h6 class="description_section">Exceptions raised</h6>
<dl class="exceptions_raised">
<dt><a class="normal" href="CastleALUtils.EALError.html">EALError</a></dt>
<dd>if alGetError returned something &lt;&gt; AL_NO_ERROR</dd>
</dl>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetSource1i"></a><code>function <b>alGetSource1i</b>(SourceName: TALuint; Attribute: TALenum): TALint;</code></td>
</tr>
<tr><td colspan="1">
<p>
Comfortable wrappers for alGet*. In many cases these should be more comfortable (because they are functions) and safer (no need to pass some pointer) than directly using related OpenAL functions.

<p>OpenAL errors are <i>not</i> checked by these functions (i.e. <a class="normal" href="CastleALUtils.html#CheckAL">CheckAL</a> or alGetError is not called).

<p>We don't check does <code>Attribute</code> really return value of given type. This means that if you will request value of the wrong type for given <code>Attribute</code>, OpenAL may do some convertion, or may set the error state. In some cases you may even get nasty access violation errors or accidental writes over some random place in memory &mdash; this may happen if for given <code>Attribute</code> OpenAL likes to return an array of some values, and you will use the wrong version (e.g. using AL_GAIN with a version that returns TALVector3f, or using AL_POSITION with a version that returns single TALfloat). So <i>always check carefully that given <code>Attribute</code> supports the requested output value.</i>

<p></p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetSource1f"></a><code>function <b>alGetSource1f</b>(SourceName: TALuint; Attribute: TALenum): TALfloat;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetSource1bool"></a><code>function <b>alGetSource1bool</b>(SourceName: TALuint; Attribute: TALenum): TALboolean;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetSource1ui"></a><code>function <b>alGetSource1ui</b>(SourceName: TALuint; Attribute: TALenum): TALuint;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetSource3f"></a><code>function <b>alGetSource3f</b>(SourceName: TALuint; Attribute: TALenum): TALVector3f;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetBuffer1sizei"></a><code>function <b>alGetBuffer1sizei</b>(BufferName: TALuint; Attribute: TALenum): TALsizei;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetBuffer1i"></a><code>function <b>alGetBuffer1i</b>(BufferName: TALuint; Attribute: TALenum): TALint;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetBuffer1f"></a><code>function <b>alGetBuffer1f</b>(BufferName: TALuint; Attribute: TALenum): TALfloat;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetListener1f"></a><code>function <b>alGetListener1f</b>(Attribute: TALenum): TALfloat;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetListener3f"></a><code>function <b>alGetListener3f</b>(Attribute: TALenum): TALVector3f;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alGetListenerOrientation"></a><code>function <b>alGetListenerOrientation</b>: TALTwoVectors3f;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alcGetInterger1"></a><code>function <b>alcGetInterger1</b>(deviceHandle:PALCdevice; token:TALenum): TALint;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alSourceVector3f"></a><code>procedure <b>alSourceVector3f</b>(SourceName: TALuint; Param: TALenum; const Value: TALVector3f);</code></td>
</tr>
<tr><td colspan="1">
<p>
Comfortable wrappers over OpenAL functions that take vector types. These take TALVector* / TALTwoVectors* types.

<p>Just like with alGet* wrappers (above in this unit), no error checking is done (no <a class="normal" href="CastleALUtils.html#CheckAL">CheckAL</a> etc.) and no checking does <code>Param</code> accept the given type of value is done.

<p></p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alListenerVector3f"></a><code>procedure <b>alListenerVector3f</b>(Param: TALenum; const Value: TALVector3f);</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alListenerOrientation"></a><code>procedure <b>alListenerOrientation</b>(const Dir, Up: TALVector3f); overload;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alListenerOrientation"></a><code>procedure <b>alListenerOrientation</b>(const Orient: TALTwoVectors3f); overload;</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alCreateSources"></a><code>procedure <b>alCreateSources</b>(n: TALsizei; sources: PALuint);</code></td>
</tr>
<tr><td colspan="1">
<p>
Allocate OpenAL sources and buffers, making sure their initial state conforms to specification.

<p>Unfortunately current Creative OpenAL Windows implementation violates OpenAL specification: default source state (i.e. newly generated source state) is not as it is specified by OpenAL implementation. Attributes MAX_DISTANCE, DIRECTION and CONE_OUTER_GAIN have different values.

<p>So <code>alCreateSources</code> calls alGenSources and then makes sure that all sources have state consistent with OpenAL specification (under Windows it means that it sets MAX_DISTANCE, DIRECTION and CONE_OUTER_GAIN attributes to their proper values). <a class="normal" href="CastleALUtils.html#alCreateBuffers">alCreateBuffers</a> does the same for alGenBuffers (which means, <i>for now</i>, that it simply calls alGenBuffers.)

<p>To be on the safe side, you should always use <code>alCreateSources</code> and <a class="normal" href="CastleALUtils.html#alCreateBuffers">alCreateBuffers</a> instead alGenSources and alGenBuffers. </p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alCreateBuffers"></a><code>procedure <b>alCreateBuffers</b>(n: TALsizei; buffers: PALuint);</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alFreeSource"></a><code>procedure <b>alFreeSource</b>(var Source: TALuint);</code></td>
</tr>
<tr><td colspan="1">
<p>
Pass resource to alDeleteSources or alDeleteBuffers, checking and setting it to zero.

<p>These are trivial wrappers over <code>alDeleteSources(1, @Source)</code>, <code>alDeleteBuffers(1, @Buffer)</code>. They first check if resource is non-zero, and after freeing set it to zero. This makes calling them many times (e.g. on already freed resources) harmless.

<p><code>alFreeSource</code> also calls alSourceStop first, because we cannot free playing sources.

<p></p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="alFreeBuffer"></a><code>procedure <b>alFreeBuffer</b>(var Buffer: TALuint);</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<h3 class="detail">Constants</h3>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="BoolToAL"></a><code><b>BoolToAL</b>: array[boolean] of TALint = (AL_FALSE, AL_TRUE);</code></td>
</tr>
<tr><td colspan="1">
&nbsp;</td></tr>
</table>
<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(["trackPageView"]);
  _paq.push(["enableLinkTracking"]);

  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://michalis.ii.uni.wroc.pl/piwik-castle-engine/";
    _paq.push(["setTrackerUrl", u+"piwik.php"]);
    _paq.push(["setSiteId", "1"]);
    var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
    g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Piwik Code -->

<noscript>
<!-- Piwik Image Tracker -->
<img src="http://michalis.ii.uni.wroc.pl/piwik-castle-engine/piwik.php?idsite=1&amp;rec=1" style="border:0" alt="" />
<!-- End Piwik -->
</noscript>
<hr noshade size="1"><span class="appinfo"><em>Generated by <a  href="http://pasdoc.sourceforge.net/">PasDoc 0.13.0</a> on 2015-06-15 04:43:08</em>
</span>
</td></tr></table></body></html>