master
ブランチ master
ShaderPlayground / deps / glm / glm / gtc / packing.hpp
35.2 KB、728行 生 Blame 履歴
1/// @ref gtc_packing
2/// @file glm/gtc/packing.hpp
3///
4/// @see core (dependence)
5///
6/// @defgroup gtc_packing GLM_GTC_packing
7/// @ingroup gtc
8///
9/// Include <glm/gtc/packing.hpp> to use the features of this extension.
10///
11/// This extension provides a set of function to convert vertors to packed
12/// formats.
13
14#pragma once
15
16// Dependency:
17#include "type_precision.hpp"
18
19#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
20# pragma message("GLM: GLM_GTC_packing extension included")
21#endif
22
23namespace glm
24{
25 /// @addtogroup gtc_packing
26 /// @{
27
28 /// First, converts the normalized floating-point value v into a 8-bit integer value.
29 /// Then, the results are packed into the returned 8-bit unsigned integer.
30 ///
31 /// The conversion for component c of v to fixed point is done as follows:
32 /// packUnorm1x8: round(clamp(c, 0, +1) * 255.0)
33 ///
34 /// @see gtc_packing
35 /// @see uint16 packUnorm2x8(vec2 const& v)
36 /// @see uint32 packUnorm4x8(vec4 const& v)
37 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
38 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
39 GLM_FUNC_DECL uint8 packUnorm1x8(float v);
40
41 /// Convert a single 8-bit integer to a normalized floating-point value.
42 ///
43 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
44 /// unpackUnorm4x8: f / 255.0
45 ///
46 /// @see gtc_packing
47 /// @see vec2 unpackUnorm2x8(uint16 p)
48 /// @see vec4 unpackUnorm4x8(uint32 p)
49 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
50 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
51 GLM_FUNC_DECL float unpackUnorm1x8(uint8 p);
52
53 /// First, converts each component of the normalized floating-point value v into 8-bit integer values.
54 /// Then, the results are packed into the returned 16-bit unsigned integer.
55 ///
56 /// The conversion for component c of v to fixed point is done as follows:
57 /// packUnorm2x8: round(clamp(c, 0, +1) * 255.0)
58 ///
59 /// The first component of the vector will be written to the least significant bits of the output;
60 /// the last component will be written to the most significant bits.
61 ///
62 /// @see gtc_packing
63 /// @see uint8 packUnorm1x8(float const& v)
64 /// @see uint32 packUnorm4x8(vec4 const& v)
65 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
66 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
67 GLM_FUNC_DECL uint16 packUnorm2x8(vec2 const& v);
68
69 /// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit unsigned integers.
70 /// Then, each component is converted to a normalized floating-point value to generate the returned two-component vector.
71 ///
72 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
73 /// unpackUnorm4x8: f / 255.0
74 ///
75 /// The first component of the returned vector will be extracted from the least significant bits of the input;
76 /// the last component will be extracted from the most significant bits.
77 ///
78 /// @see gtc_packing
79 /// @see float unpackUnorm1x8(uint8 v)
80 /// @see vec4 unpackUnorm4x8(uint32 p)
81 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
82 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
83 GLM_FUNC_DECL vec2 unpackUnorm2x8(uint16 p);
84
85 /// First, converts the normalized floating-point value v into 8-bit integer value.
86 /// Then, the results are packed into the returned 8-bit unsigned integer.
87 ///
88 /// The conversion to fixed point is done as follows:
89 /// packSnorm1x8: round(clamp(s, -1, +1) * 127.0)
90 ///
91 /// @see gtc_packing
92 /// @see uint16 packSnorm2x8(vec2 const& v)
93 /// @see uint32 packSnorm4x8(vec4 const& v)
94 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
95 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
96 GLM_FUNC_DECL uint8 packSnorm1x8(float s);
97
98 /// First, unpacks a single 8-bit unsigned integer p into a single 8-bit signed integers.
99 /// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
100 ///
101 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
102 /// unpackSnorm1x8: clamp(f / 127.0, -1, +1)
103 ///
104 /// @see gtc_packing
105 /// @see vec2 unpackSnorm2x8(uint16 p)
106 /// @see vec4 unpackSnorm4x8(uint32 p)
107 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
108 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
109 GLM_FUNC_DECL float unpackSnorm1x8(uint8 p);
110
111 /// First, converts each component of the normalized floating-point value v into 8-bit integer values.
112 /// Then, the results are packed into the returned 16-bit unsigned integer.
113 ///
114 /// The conversion for component c of v to fixed point is done as follows:
115 /// packSnorm2x8: round(clamp(c, -1, +1) * 127.0)
116 ///
117 /// The first component of the vector will be written to the least significant bits of the output;
118 /// the last component will be written to the most significant bits.
119 ///
120 /// @see gtc_packing
121 /// @see uint8 packSnorm1x8(float const& v)
122 /// @see uint32 packSnorm4x8(vec4 const& v)
123 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
124 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
125 GLM_FUNC_DECL uint16 packSnorm2x8(vec2 const& v);
126
127 /// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit signed integers.
128 /// Then, each component is converted to a normalized floating-point value to generate the returned two-component vector.
129 ///
130 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
131 /// unpackSnorm2x8: clamp(f / 127.0, -1, +1)
132 ///
133 /// The first component of the returned vector will be extracted from the least significant bits of the input;
134 /// the last component will be extracted from the most significant bits.
135 ///
136 /// @see gtc_packing
137 /// @see float unpackSnorm1x8(uint8 p)
138 /// @see vec4 unpackSnorm4x8(uint32 p)
139 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
140 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
141 GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 p);
142
143 /// First, converts the normalized floating-point value v into a 16-bit integer value.
144 /// Then, the results are packed into the returned 16-bit unsigned integer.
145 ///
146 /// The conversion for component c of v to fixed point is done as follows:
147 /// packUnorm1x16: round(clamp(c, 0, +1) * 65535.0)
148 ///
149 /// @see gtc_packing
150 /// @see uint16 packSnorm1x16(float const& v)
151 /// @see uint64 packSnorm4x16(vec4 const& v)
152 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
153 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
154 GLM_FUNC_DECL uint16 packUnorm1x16(float v);
155
156 /// First, unpacks a single 16-bit unsigned integer p into a of 16-bit unsigned integers.
157 /// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
158 ///
159 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
160 /// unpackUnorm1x16: f / 65535.0
161 ///
162 /// @see gtc_packing
163 /// @see vec2 unpackUnorm2x16(uint32 p)
164 /// @see vec4 unpackUnorm4x16(uint64 p)
165 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
166 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
167 GLM_FUNC_DECL float unpackUnorm1x16(uint16 p);
168
169 /// First, converts each component of the normalized floating-point value v into 16-bit integer values.
170 /// Then, the results are packed into the returned 64-bit unsigned integer.
171 ///
172 /// The conversion for component c of v to fixed point is done as follows:
173 /// packUnorm4x16: round(clamp(c, 0, +1) * 65535.0)
174 ///
175 /// The first component of the vector will be written to the least significant bits of the output;
176 /// the last component will be written to the most significant bits.
177 ///
178 /// @see gtc_packing
179 /// @see uint16 packUnorm1x16(float const& v)
180 /// @see uint32 packUnorm2x16(vec2 const& v)
181 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
182 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
183 GLM_FUNC_DECL uint64 packUnorm4x16(vec4 const& v);
184
185 /// First, unpacks a single 64-bit unsigned integer p into four 16-bit unsigned integers.
186 /// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
187 ///
188 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
189 /// unpackUnormx4x16: f / 65535.0
190 ///
191 /// The first component of the returned vector will be extracted from the least significant bits of the input;
192 /// the last component will be extracted from the most significant bits.
193 ///
194 /// @see gtc_packing
195 /// @see float unpackUnorm1x16(uint16 p)
196 /// @see vec2 unpackUnorm2x16(uint32 p)
197 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
198 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
199 GLM_FUNC_DECL vec4 unpackUnorm4x16(uint64 p);
200
201 /// First, converts the normalized floating-point value v into 16-bit integer value.
202 /// Then, the results are packed into the returned 16-bit unsigned integer.
203 ///
204 /// The conversion to fixed point is done as follows:
205 /// packSnorm1x8: round(clamp(s, -1, +1) * 32767.0)
206 ///
207 /// @see gtc_packing
208 /// @see uint32 packSnorm2x16(vec2 const& v)
209 /// @see uint64 packSnorm4x16(vec4 const& v)
210 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
211 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
212 GLM_FUNC_DECL uint16 packSnorm1x16(float v);
213
214 /// First, unpacks a single 16-bit unsigned integer p into a single 16-bit signed integers.
215 /// Then, each component is converted to a normalized floating-point value to generate the returned scalar.
216 ///
217 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
218 /// unpackSnorm1x16: clamp(f / 32767.0, -1, +1)
219 ///
220 /// @see gtc_packing
221 /// @see vec2 unpackSnorm2x16(uint32 p)
222 /// @see vec4 unpackSnorm4x16(uint64 p)
223 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm1x16.xml">GLSL unpackSnorm4x8 man page</a>
224 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
225 GLM_FUNC_DECL float unpackSnorm1x16(uint16 p);
226
227 /// First, converts each component of the normalized floating-point value v into 16-bit integer values.
228 /// Then, the results are packed into the returned 64-bit unsigned integer.
229 ///
230 /// The conversion for component c of v to fixed point is done as follows:
231 /// packSnorm2x8: round(clamp(c, -1, +1) * 32767.0)
232 ///
233 /// The first component of the vector will be written to the least significant bits of the output;
234 /// the last component will be written to the most significant bits.
235 ///
236 /// @see gtc_packing
237 /// @see uint16 packSnorm1x16(float const& v)
238 /// @see uint32 packSnorm2x16(vec2 const& v)
239 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
240 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
241 GLM_FUNC_DECL uint64 packSnorm4x16(vec4 const& v);
242
243 /// First, unpacks a single 64-bit unsigned integer p into four 16-bit signed integers.
244 /// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
245 ///
246 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
247 /// unpackSnorm4x16: clamp(f / 32767.0, -1, +1)
248 ///
249 /// The first component of the returned vector will be extracted from the least significant bits of the input;
250 /// the last component will be extracted from the most significant bits.
251 ///
252 /// @see gtc_packing
253 /// @see float unpackSnorm1x16(uint16 p)
254 /// @see vec2 unpackSnorm2x16(uint32 p)
255 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm2x16.xml">GLSL unpackSnorm4x8 man page</a>
256 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
257 GLM_FUNC_DECL vec4 unpackSnorm4x16(uint64 p);
258
259 /// Returns an unsigned integer obtained by converting the components of a floating-point scalar
260 /// to the 16-bit floating-point representation found in the OpenGL Specification,
261 /// and then packing this 16-bit value into a 16-bit unsigned integer.
262 ///
263 /// @see gtc_packing
264 /// @see uint32 packHalf2x16(vec2 const& v)
265 /// @see uint64 packHalf4x16(vec4 const& v)
266 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
267 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
268 GLM_FUNC_DECL uint16 packHalf1x16(float v);
269
270 /// Returns a floating-point scalar with components obtained by unpacking a 16-bit unsigned integer into a 16-bit value,
271 /// interpreted as a 16-bit floating-point number according to the OpenGL Specification,
272 /// and converting it to 32-bit floating-point values.
273 ///
274 /// @see gtc_packing
275 /// @see vec2 unpackHalf2x16(uint32 const& v)
276 /// @see vec4 unpackHalf4x16(uint64 const& v)
277 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
278 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
279 GLM_FUNC_DECL float unpackHalf1x16(uint16 v);
280
281 /// Returns an unsigned integer obtained by converting the components of a four-component floating-point vector
282 /// to the 16-bit floating-point representation found in the OpenGL Specification,
283 /// and then packing these four 16-bit values into a 64-bit unsigned integer.
284 /// The first vector component specifies the 16 least-significant bits of the result;
285 /// the forth component specifies the 16 most-significant bits.
286 ///
287 /// @see gtc_packing
288 /// @see uint16 packHalf1x16(float const& v)
289 /// @see uint32 packHalf2x16(vec2 const& v)
290 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
291 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
292 GLM_FUNC_DECL uint64 packHalf4x16(vec4 const& v);
293
294 /// Returns a four-component floating-point vector with components obtained by unpacking a 64-bit unsigned integer into four 16-bit values,
295 /// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification,
296 /// and converting them to 32-bit floating-point values.
297 /// The first component of the vector is obtained from the 16 least-significant bits of v;
298 /// the forth component is obtained from the 16 most-significant bits of v.
299 ///
300 /// @see gtc_packing
301 /// @see float unpackHalf1x16(uint16 const& v)
302 /// @see vec2 unpackHalf2x16(uint32 const& v)
303 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
304 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
305 GLM_FUNC_DECL vec4 unpackHalf4x16(uint64 p);
306
307 /// Returns an unsigned integer obtained by converting the components of a four-component signed integer vector
308 /// to the 10-10-10-2-bit signed integer representation found in the OpenGL Specification,
309 /// and then packing these four values into a 32-bit unsigned integer.
310 /// The first vector component specifies the 10 least-significant bits of the result;
311 /// the forth component specifies the 2 most-significant bits.
312 ///
313 /// @see gtc_packing
314 /// @see uint32 packI3x10_1x2(uvec4 const& v)
315 /// @see uint32 packSnorm3x10_1x2(vec4 const& v)
316 /// @see uint32 packUnorm3x10_1x2(vec4 const& v)
317 /// @see ivec4 unpackI3x10_1x2(uint32 const& p)
318 GLM_FUNC_DECL uint32 packI3x10_1x2(ivec4 const& v);
319
320 /// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit signed integers.
321 ///
322 /// The first component of the returned vector will be extracted from the least significant bits of the input;
323 /// the last component will be extracted from the most significant bits.
324 ///
325 /// @see gtc_packing
326 /// @see uint32 packU3x10_1x2(uvec4 const& v)
327 /// @see vec4 unpackSnorm3x10_1x2(uint32 const& p);
328 /// @see uvec4 unpackI3x10_1x2(uint32 const& p);
329 GLM_FUNC_DECL ivec4 unpackI3x10_1x2(uint32 p);
330
331 /// Returns an unsigned integer obtained by converting the components of a four-component unsigned integer vector
332 /// to the 10-10-10-2-bit unsigned integer representation found in the OpenGL Specification,
333 /// and then packing these four values into a 32-bit unsigned integer.
334 /// The first vector component specifies the 10 least-significant bits of the result;
335 /// the forth component specifies the 2 most-significant bits.
336 ///
337 /// @see gtc_packing
338 /// @see uint32 packI3x10_1x2(ivec4 const& v)
339 /// @see uint32 packSnorm3x10_1x2(vec4 const& v)
340 /// @see uint32 packUnorm3x10_1x2(vec4 const& v)
341 /// @see ivec4 unpackU3x10_1x2(uint32 const& p)
342 GLM_FUNC_DECL uint32 packU3x10_1x2(uvec4 const& v);
343
344 /// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit unsigned integers.
345 ///
346 /// The first component of the returned vector will be extracted from the least significant bits of the input;
347 /// the last component will be extracted from the most significant bits.
348 ///
349 /// @see gtc_packing
350 /// @see uint32 packU3x10_1x2(uvec4 const& v)
351 /// @see vec4 unpackSnorm3x10_1x2(uint32 const& p);
352 /// @see uvec4 unpackI3x10_1x2(uint32 const& p);
353 GLM_FUNC_DECL uvec4 unpackU3x10_1x2(uint32 p);
354
355 /// First, converts the first three components of the normalized floating-point value v into 10-bit signed integer values.
356 /// Then, converts the forth component of the normalized floating-point value v into 2-bit signed integer values.
357 /// Then, the results are packed into the returned 32-bit unsigned integer.
358 ///
359 /// The conversion for component c of v to fixed point is done as follows:
360 /// packSnorm3x10_1x2(xyz): round(clamp(c, -1, +1) * 511.0)
361 /// packSnorm3x10_1x2(w): round(clamp(c, -1, +1) * 1.0)
362 ///
363 /// The first vector component specifies the 10 least-significant bits of the result;
364 /// the forth component specifies the 2 most-significant bits.
365 ///
366 /// @see gtc_packing
367 /// @see vec4 unpackSnorm3x10_1x2(uint32 const& p)
368 /// @see uint32 packUnorm3x10_1x2(vec4 const& v)
369 /// @see uint32 packU3x10_1x2(uvec4 const& v)
370 /// @see uint32 packI3x10_1x2(ivec4 const& v)
371 GLM_FUNC_DECL uint32 packSnorm3x10_1x2(vec4 const& v);
372
373 /// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers.
374 /// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
375 ///
376 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
377 /// unpackSnorm3x10_1x2(xyz): clamp(f / 511.0, -1, +1)
378 /// unpackSnorm3x10_1x2(w): clamp(f / 511.0, -1, +1)
379 ///
380 /// The first component of the returned vector will be extracted from the least significant bits of the input;
381 /// the last component will be extracted from the most significant bits.
382 ///
383 /// @see gtc_packing
384 /// @see uint32 packSnorm3x10_1x2(vec4 const& v)
385 /// @see vec4 unpackUnorm3x10_1x2(uint32 const& p))
386 /// @see uvec4 unpackI3x10_1x2(uint32 const& p)
387 /// @see uvec4 unpackU3x10_1x2(uint32 const& p)
388 GLM_FUNC_DECL vec4 unpackSnorm3x10_1x2(uint32 p);
389
390 /// First, converts the first three components of the normalized floating-point value v into 10-bit unsigned integer values.
391 /// Then, converts the forth component of the normalized floating-point value v into 2-bit signed uninteger values.
392 /// Then, the results are packed into the returned 32-bit unsigned integer.
393 ///
394 /// The conversion for component c of v to fixed point is done as follows:
395 /// packUnorm3x10_1x2(xyz): round(clamp(c, 0, +1) * 1023.0)
396 /// packUnorm3x10_1x2(w): round(clamp(c, 0, +1) * 3.0)
397 ///
398 /// The first vector component specifies the 10 least-significant bits of the result;
399 /// the forth component specifies the 2 most-significant bits.
400 ///
401 /// @see gtc_packing
402 /// @see vec4 unpackUnorm3x10_1x2(uint32 const& p)
403 /// @see uint32 packUnorm3x10_1x2(vec4 const& v)
404 /// @see uint32 packU3x10_1x2(uvec4 const& v)
405 /// @see uint32 packI3x10_1x2(ivec4 const& v)
406 GLM_FUNC_DECL uint32 packUnorm3x10_1x2(vec4 const& v);
407
408 /// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers.
409 /// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
410 ///
411 /// The conversion for unpacked fixed-point value f to floating point is done as follows:
412 /// unpackSnorm3x10_1x2(xyz): clamp(f / 1023.0, 0, +1)
413 /// unpackSnorm3x10_1x2(w): clamp(f / 3.0, 0, +1)
414 ///
415 /// The first component of the returned vector will be extracted from the least significant bits of the input;
416 /// the last component will be extracted from the most significant bits.
417 ///
418 /// @see gtc_packing
419 /// @see uint32 packSnorm3x10_1x2(vec4 const& v)
420 /// @see vec4 unpackInorm3x10_1x2(uint32 const& p))
421 /// @see uvec4 unpackI3x10_1x2(uint32 const& p)
422 /// @see uvec4 unpackU3x10_1x2(uint32 const& p)
423 GLM_FUNC_DECL vec4 unpackUnorm3x10_1x2(uint32 p);
424
425 /// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values.
426 /// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value.
427 /// Then, the results are packed into the returned 32-bit unsigned integer.
428 ///
429 /// The first vector component specifies the 11 least-significant bits of the result;
430 /// the last component specifies the 10 most-significant bits.
431 ///
432 /// @see gtc_packing
433 /// @see vec3 unpackF2x11_1x10(uint32 const& p)
434 GLM_FUNC_DECL uint32 packF2x11_1x10(vec3 const& v);
435
436 /// First, unpacks a single 32-bit unsigned integer p into two 11-bit signless floating-point values and one 10-bit signless floating-point value .
437 /// Then, each component is converted to a normalized floating-point value to generate the returned three-component vector.
438 ///
439 /// The first component of the returned vector will be extracted from the least significant bits of the input;
440 /// the last component will be extracted from the most significant bits.
441 ///
442 /// @see gtc_packing
443 /// @see uint32 packF2x11_1x10(vec3 const& v)
444 GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 p);
445
446
447 /// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values.
448 /// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value.
449 /// Then, the results are packed into the returned 32-bit unsigned integer.
450 ///
451 /// The first vector component specifies the 11 least-significant bits of the result;
452 /// the last component specifies the 10 most-significant bits.
453 ///
454 /// packF3x9_E1x5 allows encoding into RGBE / RGB9E5 format
455 ///
456 /// @see gtc_packing
457 /// @see vec3 unpackF3x9_E1x5(uint32 const& p)
458 GLM_FUNC_DECL uint32 packF3x9_E1x5(vec3 const& v);
459
460 /// First, unpacks a single 32-bit unsigned integer p into two 11-bit signless floating-point values and one 10-bit signless floating-point value .
461 /// Then, each component is converted to a normalized floating-point value to generate the returned three-component vector.
462 ///
463 /// The first component of the returned vector will be extracted from the least significant bits of the input;
464 /// the last component will be extracted from the most significant bits.
465 ///
466 /// unpackF3x9_E1x5 allows decoding RGBE / RGB9E5 data
467 ///
468 /// @see gtc_packing
469 /// @see uint32 packF3x9_E1x5(vec3 const& v)
470 GLM_FUNC_DECL vec3 unpackF3x9_E1x5(uint32 p);
471
472 /// Returns an unsigned integer vector obtained by converting the components of a floating-point vector
473 /// to the 16-bit floating-point representation found in the OpenGL Specification.
474 /// The first vector component specifies the 16 least-significant bits of the result;
475 /// the forth component specifies the 16 most-significant bits.
476 ///
477 /// @see gtc_packing
478 /// @see vec<3, T, Q> unpackRGBM(vec<4, T, Q> const& p)
479 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
480 template<length_t L, typename T, qualifier Q>
481 GLM_FUNC_DECL vec<4, T, Q> packRGBM(vec<3, T, Q> const& rgb);
482
483 /// Returns a floating-point vector with components obtained by reinterpreting an integer vector as 16-bit floating-point numbers and converting them to 32-bit floating-point values.
484 /// The first component of the vector is obtained from the 16 least-significant bits of v;
485 /// the forth component is obtained from the 16 most-significant bits of v.
486 ///
487 /// @see gtc_packing
488 /// @see vec<4, T, Q> packRGBM(vec<3, float, Q> const& v)
489 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
490 template<length_t L, typename T, qualifier Q>
491 GLM_FUNC_DECL vec<3, T, Q> unpackRGBM(vec<4, T, Q> const& rgbm);
492
493 /// Returns an unsigned integer vector obtained by converting the components of a floating-point vector
494 /// to the 16-bit floating-point representation found in the OpenGL Specification.
495 /// The first vector component specifies the 16 least-significant bits of the result;
496 /// the forth component specifies the 16 most-significant bits.
497 ///
498 /// @see gtc_packing
499 /// @see vec<L, float, Q> unpackHalf(vec<L, uint16, Q> const& p)
500 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
501 template<length_t L, qualifier Q>
502 GLM_FUNC_DECL vec<L, uint16, Q> packHalf(vec<L, float, Q> const& v);
503
504 /// Returns a floating-point vector with components obtained by reinterpreting an integer vector as 16-bit floating-point numbers and converting them to 32-bit floating-point values.
505 /// The first component of the vector is obtained from the 16 least-significant bits of v;
506 /// the forth component is obtained from the 16 most-significant bits of v.
507 ///
508 /// @see gtc_packing
509 /// @see vec<L, uint16, Q> packHalf(vec<L, float, Q> const& v)
510 /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
511 template<length_t L, qualifier Q>
512 GLM_FUNC_DECL vec<L, float, Q> unpackHalf(vec<L, uint16, Q> const& p);
513
514 /// Convert each component of the normalized floating-point vector into unsigned integer values.
515 ///
516 /// @see gtc_packing
517 /// @see vec<L, floatType, Q> unpackUnorm(vec<L, intType, Q> const& p);
518 template<typename uintType, length_t L, typename floatType, qualifier Q>
519 GLM_FUNC_DECL vec<L, uintType, Q> packUnorm(vec<L, floatType, Q> const& v);
520
521 /// Convert a packed integer to a normalized floating-point vector.
522 ///
523 /// @see gtc_packing
524 /// @see vec<L, intType, Q> packUnorm(vec<L, floatType, Q> const& v)
525 template<typename floatType, length_t L, typename uintType, qualifier Q>
526 GLM_FUNC_DECL vec<L, floatType, Q> unpackUnorm(vec<L, uintType, Q> const& v);
527
528 /// Convert each component of the normalized floating-point vector into signed integer values.
529 ///
530 /// @see gtc_packing
531 /// @see vec<L, floatType, Q> unpackSnorm(vec<L, intType, Q> const& p);
532 template<typename intType, length_t L, typename floatType, qualifier Q>
533 GLM_FUNC_DECL vec<L, intType, Q> packSnorm(vec<L, floatType, Q> const& v);
534
535 /// Convert a packed integer to a normalized floating-point vector.
536 ///
537 /// @see gtc_packing
538 /// @see vec<L, intType, Q> packSnorm(vec<L, floatType, Q> const& v)
539 template<typename floatType, length_t L, typename intType, qualifier Q>
540 GLM_FUNC_DECL vec<L, floatType, Q> unpackSnorm(vec<L, intType, Q> const& v);
541
542 /// Convert each component of the normalized floating-point vector into unsigned integer values.
543 ///
544 /// @see gtc_packing
545 /// @see vec2 unpackUnorm2x4(uint8 p)
546 GLM_FUNC_DECL uint8 packUnorm2x4(vec2 const& v);
547
548 /// Convert a packed integer to a normalized floating-point vector.
549 ///
550 /// @see gtc_packing
551 /// @see uint8 packUnorm2x4(vec2 const& v)
552 GLM_FUNC_DECL vec2 unpackUnorm2x4(uint8 p);
553
554 /// Convert each component of the normalized floating-point vector into unsigned integer values.
555 ///
556 /// @see gtc_packing
557 /// @see vec4 unpackUnorm4x4(uint16 p)
558 GLM_FUNC_DECL uint16 packUnorm4x4(vec4 const& v);
559
560 /// Convert a packed integer to a normalized floating-point vector.
561 ///
562 /// @see gtc_packing
563 /// @see uint16 packUnorm4x4(vec4 const& v)
564 GLM_FUNC_DECL vec4 unpackUnorm4x4(uint16 p);
565
566 /// Convert each component of the normalized floating-point vector into unsigned integer values.
567 ///
568 /// @see gtc_packing
569 /// @see vec3 unpackUnorm1x5_1x6_1x5(uint16 p)
570 GLM_FUNC_DECL uint16 packUnorm1x5_1x6_1x5(vec3 const& v);
571
572 /// Convert a packed integer to a normalized floating-point vector.
573 ///
574 /// @see gtc_packing
575 /// @see uint16 packUnorm1x5_1x6_1x5(vec3 const& v)
576 GLM_FUNC_DECL vec3 unpackUnorm1x5_1x6_1x5(uint16 p);
577
578 /// Convert each component of the normalized floating-point vector into unsigned integer values.
579 ///
580 /// @see gtc_packing
581 /// @see vec4 unpackUnorm3x5_1x1(uint16 p)
582 GLM_FUNC_DECL uint16 packUnorm3x5_1x1(vec4 const& v);
583
584 /// Convert a packed integer to a normalized floating-point vector.
585 ///
586 /// @see gtc_packing
587 /// @see uint16 packUnorm3x5_1x1(vec4 const& v)
588 GLM_FUNC_DECL vec4 unpackUnorm3x5_1x1(uint16 p);
589
590 /// Convert each component of the normalized floating-point vector into unsigned integer values.
591 ///
592 /// @see gtc_packing
593 /// @see vec3 unpackUnorm2x3_1x2(uint8 p)
594 GLM_FUNC_DECL uint8 packUnorm2x3_1x2(vec3 const& v);
595
596 /// Convert a packed integer to a normalized floating-point vector.
597 ///
598 /// @see gtc_packing
599 /// @see uint8 packUnorm2x3_1x2(vec3 const& v)
600 GLM_FUNC_DECL vec3 unpackUnorm2x3_1x2(uint8 p);
601
602
603
604 /// Convert each component from an integer vector into a packed unsigned integer.
605 ///
606 /// @see gtc_packing
607 /// @see i8vec2 unpackInt2x8(int16 p)
608 GLM_FUNC_DECL int16 packInt2x8(i8vec2 const& v);
609
610 /// Convert a packed integer into an integer vector.
611 ///
612 /// @see gtc_packing
613 /// @see int16 packInt2x8(i8vec2 const& v)
614 GLM_FUNC_DECL i8vec2 unpackInt2x8(int16 p);
615
616 /// Convert each component from an integer vector into a packed unsigned integer.
617 ///
618 /// @see gtc_packing
619 /// @see u8vec2 unpackInt2x8(uint16 p)
620 GLM_FUNC_DECL uint16 packUint2x8(u8vec2 const& v);
621
622 /// Convert a packed integer into an integer vector.
623 ///
624 /// @see gtc_packing
625 /// @see uint16 packInt2x8(u8vec2 const& v)
626 GLM_FUNC_DECL u8vec2 unpackUint2x8(uint16 p);
627
628 /// Convert each component from an integer vector into a packed unsigned integer.
629 ///
630 /// @see gtc_packing
631 /// @see i8vec4 unpackInt4x8(int32 p)
632 GLM_FUNC_DECL int32 packInt4x8(i8vec4 const& v);
633
634 /// Convert a packed integer into an integer vector.
635 ///
636 /// @see gtc_packing
637 /// @see int32 packInt2x8(i8vec4 const& v)
638 GLM_FUNC_DECL i8vec4 unpackInt4x8(int32 p);
639
640 /// Convert each component from an integer vector into a packed unsigned integer.
641 ///
642 /// @see gtc_packing
643 /// @see u8vec4 unpackUint4x8(uint32 p)
644 GLM_FUNC_DECL uint32 packUint4x8(u8vec4 const& v);
645
646 /// Convert a packed integer into an integer vector.
647 ///
648 /// @see gtc_packing
649 /// @see uint32 packUint4x8(u8vec2 const& v)
650 GLM_FUNC_DECL u8vec4 unpackUint4x8(uint32 p);
651
652 /// Convert each component from an integer vector into a packed unsigned integer.
653 ///
654 /// @see gtc_packing
655 /// @see i16vec2 unpackInt2x16(int p)
656 GLM_FUNC_DECL int packInt2x16(i16vec2 const& v);
657
658 /// Convert a packed integer into an integer vector.
659 ///
660 /// @see gtc_packing
661 /// @see int packInt2x16(i16vec2 const& v)
662 GLM_FUNC_DECL i16vec2 unpackInt2x16(int p);
663
664 /// Convert each component from an integer vector into a packed unsigned integer.
665 ///
666 /// @see gtc_packing
667 /// @see i16vec4 unpackInt4x16(int64 p)
668 GLM_FUNC_DECL int64 packInt4x16(i16vec4 const& v);
669
670 /// Convert a packed integer into an integer vector.
671 ///
672 /// @see gtc_packing
673 /// @see int64 packInt4x16(i16vec4 const& v)
674 GLM_FUNC_DECL i16vec4 unpackInt4x16(int64 p);
675
676 /// Convert each component from an integer vector into a packed unsigned integer.
677 ///
678 /// @see gtc_packing
679 /// @see u16vec2 unpackUint2x16(uint p)
680 GLM_FUNC_DECL uint packUint2x16(u16vec2 const& v);
681
682 /// Convert a packed integer into an integer vector.
683 ///
684 /// @see gtc_packing
685 /// @see uint packUint2x16(u16vec2 const& v)
686 GLM_FUNC_DECL u16vec2 unpackUint2x16(uint p);
687
688 /// Convert each component from an integer vector into a packed unsigned integer.
689 ///
690 /// @see gtc_packing
691 /// @see u16vec4 unpackUint4x16(uint64 p)
692 GLM_FUNC_DECL uint64 packUint4x16(u16vec4 const& v);
693
694 /// Convert a packed integer into an integer vector.
695 ///
696 /// @see gtc_packing
697 /// @see uint64 packUint4x16(u16vec4 const& v)
698 GLM_FUNC_DECL u16vec4 unpackUint4x16(uint64 p);
699
700 /// Convert each component from an integer vector into a packed unsigned integer.
701 ///
702 /// @see gtc_packing
703 /// @see i32vec2 unpackInt2x32(int p)
704 GLM_FUNC_DECL int64 packInt2x32(i32vec2 const& v);
705
706 /// Convert a packed integer into an integer vector.
707 ///
708 /// @see gtc_packing
709 /// @see int packInt2x16(i32vec2 const& v)
710 GLM_FUNC_DECL i32vec2 unpackInt2x32(int64 p);
711
712 /// Convert each component from an integer vector into a packed unsigned integer.
713 ///
714 /// @see gtc_packing
715 /// @see u32vec2 unpackUint2x32(int p)
716 GLM_FUNC_DECL uint64 packUint2x32(u32vec2 const& v);
717
718 /// Convert a packed integer into an integer vector.
719 ///
720 /// @see gtc_packing
721 /// @see int packUint2x16(u32vec2 const& v)
722 GLM_FUNC_DECL u32vec2 unpackUint2x32(uint64 p);
723
724
725 /// @}
726}// namespace glm
727
728#include "packing.inl"