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