1 /////////////////////////////////////////////////////////////////////////////////// 2 /// OpenGL Mathematics (glm.g-truc.net) 3 /// 4 /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 /// of this software and associated documentation files (the "Software"), to deal 7 /// in the Software without restriction, including without limitation the rights 8 /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 /// copies of the Software, and to permit persons to whom the Software is 10 /// furnished to do so, subject to the following conditions: 11 /// 12 /// The above copyright notice and this permission notice shall be included in 13 /// all copies or substantial portions of the Software. 14 /// 15 /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 /// THE SOFTWARE. 22 /// 23 /// @ref gtc_packing 24 /// @file glm/gtc/packing.hpp 25 /// @date 2013-08-08 / 2013-08-08 26 /// @author Christophe Riccio 27 /// 28 /// @see core (dependence) 29 /// 30 /// @defgroup gtc_packing GLM_GTC_packing 31 /// @ingroup gtc 32 /// 33 /// @brief This extension provides a set of function to convert vertors to packed 34 /// formats. 35 /// 36 /// <glm/gtc/packing.hpp> need to be included to use these features. 37 /////////////////////////////////////////////////////////////////////////////////// 38 39 #ifndef GLM_GTC_packing 40 #define GLM_GTC_packing 41 42 // Dependency: 43 #include "type_precision.hpp" 44 45 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 46 # pragma message("GLM: GLM_GTC_packing extension included") 47 #endif 48 49 namespace glm 50 { 51 /// @addtogroup gtc_packing 52 /// @{ 53 54 /// First, converts the normalized floating-point value v into a 8-bit integer value. 55 /// Then, the results are packed into the returned 8-bit unsigned integer. 56 /// 57 /// The conversion for component c of v to fixed point is done as follows: 58 /// packUnorm1x8: round(clamp(c, 0, +1) * 255.0) 59 /// 60 /// @see gtc_packing 61 /// @see uint16 packUnorm2x8(vec2 const & v) 62 /// @see uint32 packUnorm4x8(vec4 const & v) 63 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a> 64 /// @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> 65 GLM_FUNC_DECL uint8 packUnorm1x8(float const & v); 66 67 /// Convert a single 8-bit integer to a normalized floating-point value. 68 /// 69 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 70 /// unpackUnorm4x8: f / 255.0 71 /// 72 /// @see gtc_packing 73 /// @see vec2 unpackUnorm2x8(uint16 p) 74 /// @see vec4 unpackUnorm4x8(uint32 p) 75 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a> 76 /// @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> 77 GLM_FUNC_DECL float unpackUnorm1x8(uint8 const & p); 78 79 /// First, converts each component of the normalized floating-point value v into 8-bit integer values. 80 /// Then, the results are packed into the returned 16-bit unsigned integer. 81 /// 82 /// The conversion for component c of v to fixed point is done as follows: 83 /// packUnorm2x8: round(clamp(c, 0, +1) * 255.0) 84 /// 85 /// The first component of the vector will be written to the least significant bits of the output; 86 /// the last component will be written to the most significant bits. 87 /// 88 /// @see gtc_packing 89 /// @see uint8 packUnorm1x8(float const & v) 90 /// @see uint32 packUnorm4x8(vec4 const & v) 91 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a> 92 /// @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> 93 GLM_FUNC_DECL uint16 packUnorm2x8(vec2 const & v); 94 95 /// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit unsigned integers. 96 /// Then, each component is converted to a normalized floating-point value to generate the returned two-component vector. 97 /// 98 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 99 /// unpackUnorm4x8: f / 255.0 100 /// 101 /// The first component of the returned vector will be extracted from the least significant bits of the input; 102 /// the last component will be extracted from the most significant bits. 103 /// 104 /// @see gtc_packing 105 /// @see float unpackUnorm1x8(uint8 v) 106 /// @see vec4 unpackUnorm4x8(uint32 p) 107 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 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 vec2 unpackUnorm2x8(uint16 const & p); 110 111 /// First, converts the normalized floating-point value v into 8-bit integer value. 112 /// Then, the results are packed into the returned 8-bit unsigned integer. 113 /// 114 /// The conversion to fixed point is done as follows: 115 /// packSnorm1x8: round(clamp(s, -1, +1) * 127.0) 116 /// 117 /// @see gtc_packing 118 /// @see uint16 packSnorm2x8(vec2 const & v) 119 /// @see uint32 packSnorm4x8(vec4 const & v) 120 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a> 121 /// @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> 122 GLM_FUNC_DECL uint8 packSnorm1x8(float const & s); 123 124 /// First, unpacks a single 8-bit unsigned integer p into a single 8-bit signed integers. 125 /// Then, the value is converted to a normalized floating-point value to generate the returned scalar. 126 /// 127 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 128 /// unpackSnorm1x8: clamp(f / 127.0, -1, +1) 129 /// 130 /// @see gtc_packing 131 /// @see vec2 unpackSnorm2x8(uint16 p) 132 /// @see vec4 unpackSnorm4x8(uint32 p) 133 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a> 134 /// @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> 135 GLM_FUNC_DECL float unpackSnorm1x8(uint8 const & p); 136 137 /// First, converts each component of the normalized floating-point value v into 8-bit integer values. 138 /// Then, the results are packed into the returned 16-bit unsigned integer. 139 /// 140 /// The conversion for component c of v to fixed point is done as follows: 141 /// packSnorm2x8: round(clamp(c, -1, +1) * 127.0) 142 /// 143 /// The first component of the vector will be written to the least significant bits of the output; 144 /// the last component will be written to the most significant bits. 145 /// 146 /// @see gtc_packing 147 /// @see uint8 packSnorm1x8(float const & v) 148 /// @see uint32 packSnorm4x8(vec4 const & v) 149 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a> 150 /// @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> 151 GLM_FUNC_DECL uint16 packSnorm2x8(vec2 const & v); 152 153 /// First, unpacks a single 16-bit unsigned integer p into a pair of 8-bit signed integers. 154 /// Then, each component is converted to a normalized floating-point value to generate the returned two-component vector. 155 /// 156 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 157 /// unpackSnorm2x8: clamp(f / 127.0, -1, +1) 158 /// 159 /// The first component of the returned vector will be extracted from the least significant bits of the input; 160 /// the last component will be extracted from the most significant bits. 161 /// 162 /// @see gtc_packing 163 /// @see float unpackSnorm1x8(uint8 p) 164 /// @see vec4 unpackSnorm4x8(uint32 p) 165 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 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 vec2 unpackSnorm2x8(uint16 const & p); 168 169 /// First, converts the normalized floating-point value v into a 16-bit integer value. 170 /// Then, the results are packed into the returned 16-bit unsigned integer. 171 /// 172 /// The conversion for component c of v to fixed point is done as follows: 173 /// packUnorm1x16: round(clamp(c, 0, +1) * 65535.0) 174 /// 175 /// @see gtc_packing 176 /// @see uint16 packSnorm1x16(float const & v) 177 /// @see uint64 packSnorm4x16(vec4 const & v) 178 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a> 179 /// @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> 180 GLM_FUNC_DECL uint16 packUnorm1x16(float const & v); 181 182 /// First, unpacks a single 16-bit unsigned integer p into a of 16-bit unsigned integers. 183 /// Then, the value is converted to a normalized floating-point value to generate the returned scalar. 184 /// 185 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 186 /// unpackUnorm1x16: f / 65535.0 187 /// 188 /// @see gtc_packing 189 /// @see vec2 unpackUnorm2x16(uint32 p) 190 /// @see vec4 unpackUnorm4x16(uint64 p) 191 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a> 192 /// @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> 193 GLM_FUNC_DECL float unpackUnorm1x16(uint16 const & p); 194 195 /// First, converts each component of the normalized floating-point value v into 16-bit integer values. 196 /// Then, the results are packed into the returned 64-bit unsigned integer. 197 /// 198 /// The conversion for component c of v to fixed point is done as follows: 199 /// packUnorm4x16: round(clamp(c, 0, +1) * 65535.0) 200 /// 201 /// The first component of the vector will be written to the least significant bits of the output; 202 /// the last component will be written to the most significant bits. 203 /// 204 /// @see gtc_packing 205 /// @see uint16 packUnorm1x16(float const & v) 206 /// @see uint32 packUnorm2x16(vec2 const & v) 207 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a> 208 /// @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> 209 GLM_FUNC_DECL uint64 packUnorm4x16(vec4 const & v); 210 211 /// First, unpacks a single 64-bit unsigned integer p into four 16-bit unsigned integers. 212 /// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector. 213 /// 214 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 215 /// unpackUnormx4x16: f / 65535.0 216 /// 217 /// The first component of the returned vector will be extracted from the least significant bits of the input; 218 /// the last component will be extracted from the most significant bits. 219 /// 220 /// @see gtc_packing 221 /// @see float unpackUnorm1x16(uint16 p) 222 /// @see vec2 unpackUnorm2x16(uint32 p) 223 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 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 vec4 unpackUnorm4x16(uint64 const & p); 226 227 /// First, converts the normalized floating-point value v into 16-bit integer value. 228 /// Then, the results are packed into the returned 16-bit unsigned integer. 229 /// 230 /// The conversion to fixed point is done as follows: 231 /// packSnorm1x8: round(clamp(s, -1, +1) * 32767.0) 232 /// 233 /// @see gtc_packing 234 /// @see uint32 packSnorm2x16(vec2 const & v) 235 /// @see uint64 packSnorm4x16(vec4 const & v) 236 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a> 237 /// @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> 238 GLM_FUNC_DECL uint16 packSnorm1x16(float const & v); 239 240 /// First, unpacks a single 16-bit unsigned integer p into a single 16-bit signed integers. 241 /// Then, each component is converted to a normalized floating-point value to generate the returned scalar. 242 /// 243 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 244 /// unpackSnorm1x16: clamp(f / 32767.0, -1, +1) 245 /// 246 /// @see gtc_packing 247 /// @see vec2 unpackSnorm2x16(uint32 p) 248 /// @see vec4 unpackSnorm4x16(uint64 p) 249 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm1x16.xml">GLSL unpackSnorm4x8 man page</a> 250 /// @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> 251 GLM_FUNC_DECL float unpackSnorm1x16(uint16 const & p); 252 253 /// First, converts each component of the normalized floating-point value v into 16-bit integer values. 254 /// Then, the results are packed into the returned 64-bit unsigned integer. 255 /// 256 /// The conversion for component c of v to fixed point is done as follows: 257 /// packSnorm2x8: round(clamp(c, -1, +1) * 32767.0) 258 /// 259 /// The first component of the vector will be written to the least significant bits of the output; 260 /// the last component will be written to the most significant bits. 261 /// 262 /// @see gtc_packing 263 /// @see uint16 packSnorm1x16(float const & v) 264 /// @see uint32 packSnorm2x16(vec2 const & v) 265 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a> 266 /// @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> 267 GLM_FUNC_DECL uint64 packSnorm4x16(vec4 const & v); 268 269 /// First, unpacks a single 64-bit unsigned integer p into four 16-bit signed integers. 270 /// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector. 271 /// 272 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 273 /// unpackSnorm4x16: clamp(f / 32767.0, -1, +1) 274 /// 275 /// The first component of the returned vector will be extracted from the least significant bits of the input; 276 /// the last component will be extracted from the most significant bits. 277 /// 278 /// @see gtc_packing 279 /// @see float unpackSnorm1x16(uint16 p) 280 /// @see vec2 unpackSnorm2x16(uint32 p) 281 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm2x16.xml">GLSL unpackSnorm4x8 man page</a> 282 /// @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> 283 GLM_FUNC_DECL vec4 unpackSnorm4x16(uint64 const & p); 284 285 /// Returns an unsigned integer obtained by converting the components of a floating-point scalar 286 /// to the 16-bit floating-point representation found in the OpenGL Specification, 287 /// and then packing this 16-bit value into a 16-bit unsigned integer. 288 /// 289 /// @see gtc_packing 290 /// @see uint32 packHalf2x16(vec2 const & v) 291 /// @see uint64 packHalf4x16(vec4 const & v) 292 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a> 293 /// @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> 294 GLM_FUNC_DECL uint16 packHalf1x16(float const & v); 295 296 /// Returns a floating-point scalar with components obtained by unpacking a 16-bit unsigned integer into a 16-bit value, 297 /// interpreted as a 16-bit floating-point number according to the OpenGL Specification, 298 /// and converting it to 32-bit floating-point values. 299 /// 300 /// @see gtc_packing 301 /// @see vec2 unpackHalf2x16(uint32 const & v) 302 /// @see vec4 unpackHalf4x16(uint64 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 float unpackHalf1x16(uint16 const & v); 306 307 /// Returns an unsigned integer obtained by converting the components of a four-component floating-point vector 308 /// to the 16-bit floating-point representation found in the OpenGL Specification, 309 /// and then packing these four 16-bit values into a 64-bit unsigned integer. 310 /// The first vector component specifies the 16 least-significant bits of the result; 311 /// the forth component specifies the 16 most-significant bits. 312 /// 313 /// @see gtc_packing 314 /// @see uint16 packHalf1x16(float const & v) 315 /// @see uint32 packHalf2x16(vec2 const & v) 316 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a> 317 /// @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> 318 GLM_FUNC_DECL uint64 packHalf4x16(vec4 const & v); 319 320 /// Returns a four-component floating-point vector with components obtained by unpacking a 64-bit unsigned integer into four 16-bit values, 321 /// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification, 322 /// and converting them to 32-bit floating-point values. 323 /// The first component of the vector is obtained from the 16 least-significant bits of v; 324 /// the forth component is obtained from the 16 most-significant bits of v. 325 /// 326 /// @see gtc_packing 327 /// @see float unpackHalf1x16(uint16 const & v) 328 /// @see vec2 unpackHalf2x16(uint32 const & v) 329 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a> 330 /// @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> 331 GLM_FUNC_DECL vec4 unpackHalf4x16(uint64 const & p); 332 333 /// Returns an unsigned integer obtained by converting the components of a four-component signed integer vector 334 /// to the 10-10-10-2-bit signed integer representation found in the OpenGL Specification, 335 /// and then packing these four values into a 32-bit unsigned integer. 336 /// The first vector component specifies the 10 least-significant bits of the result; 337 /// the forth component specifies the 2 most-significant bits. 338 /// 339 /// @see gtc_packing 340 /// @see uint32 packI3x10_1x2(uvec4 const & v) 341 /// @see uint32 packSnorm3x10_1x2(vec4 const & v) 342 /// @see uint32 packUnorm3x10_1x2(vec4 const & v) 343 /// @see ivec4 unpackI3x10_1x2(uint32 const & p) 344 GLM_FUNC_DECL uint32 packI3x10_1x2(ivec4 const & v); 345 346 /// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit signed integers. 347 /// 348 /// The first component of the returned vector will be extracted from the least significant bits of the input; 349 /// the last component will be extracted from the most significant bits. 350 /// 351 /// @see gtc_packing 352 /// @see uint32 packU3x10_1x2(uvec4 const & v) 353 /// @see vec4 unpackSnorm3x10_1x2(uint32 const & p); 354 /// @see uvec4 unpackI3x10_1x2(uint32 const & p); 355 GLM_FUNC_DECL ivec4 unpackI3x10_1x2(uint32 const & p); 356 357 /// Returns an unsigned integer obtained by converting the components of a four-component unsigned integer vector 358 /// to the 10-10-10-2-bit unsigned integer representation found in the OpenGL Specification, 359 /// and then packing these four values into a 32-bit unsigned integer. 360 /// The first vector component specifies the 10 least-significant bits of the result; 361 /// the forth component specifies the 2 most-significant bits. 362 /// 363 /// @see gtc_packing 364 /// @see uint32 packI3x10_1x2(ivec4 const & v) 365 /// @see uint32 packSnorm3x10_1x2(vec4 const & v) 366 /// @see uint32 packUnorm3x10_1x2(vec4 const & v) 367 /// @see ivec4 unpackU3x10_1x2(uint32 const & p) 368 GLM_FUNC_DECL uint32 packU3x10_1x2(uvec4 const & v); 369 370 /// Unpacks a single 32-bit unsigned integer p into three 10-bit and one 2-bit unsigned integers. 371 /// 372 /// The first component of the returned vector will be extracted from the least significant bits of the input; 373 /// the last component will be extracted from the most significant bits. 374 /// 375 /// @see gtc_packing 376 /// @see uint32 packU3x10_1x2(uvec4 const & v) 377 /// @see vec4 unpackSnorm3x10_1x2(uint32 const & p); 378 /// @see uvec4 unpackI3x10_1x2(uint32 const & p); 379 GLM_FUNC_DECL uvec4 unpackU3x10_1x2(uint32 const & p); 380 381 /// First, converts the first three components of the normalized floating-point value v into 10-bit signed integer values. 382 /// Then, converts the forth component of the normalized floating-point value v into 2-bit signed integer values. 383 /// Then, the results are packed into the returned 32-bit unsigned integer. 384 /// 385 /// The conversion for component c of v to fixed point is done as follows: 386 /// packSnorm3x10_1x2(xyz): round(clamp(c, -1, +1) * 511.0) 387 /// packSnorm3x10_1x2(w): round(clamp(c, -1, +1) * 1.0) 388 /// 389 /// The first vector component specifies the 10 least-significant bits of the result; 390 /// the forth component specifies the 2 most-significant bits. 391 /// 392 /// @see gtc_packing 393 /// @see vec4 unpackSnorm3x10_1x2(uint32 const & p) 394 /// @see uint32 packUnorm3x10_1x2(vec4 const & v) 395 /// @see uint32 packU3x10_1x2(uvec4 const & v) 396 /// @see uint32 packI3x10_1x2(ivec4 const & v) 397 GLM_FUNC_DECL uint32 packSnorm3x10_1x2(vec4 const & v); 398 399 /// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers. 400 /// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector. 401 /// 402 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 403 /// unpackSnorm3x10_1x2(xyz): clamp(f / 511.0, -1, +1) 404 /// unpackSnorm3x10_1x2(w): clamp(f / 511.0, -1, +1) 405 /// 406 /// The first component of the returned vector will be extracted from the least significant bits of the input; 407 /// the last component will be extracted from the most significant bits. 408 /// 409 /// @see gtc_packing 410 /// @see uint32 packSnorm3x10_1x2(vec4 const & v) 411 /// @see vec4 unpackUnorm3x10_1x2(uint32 const & p)) 412 /// @see uvec4 unpackI3x10_1x2(uint32 const & p) 413 /// @see uvec4 unpackU3x10_1x2(uint32 const & p) 414 GLM_FUNC_DECL vec4 unpackSnorm3x10_1x2(uint32 const & p); 415 416 /// First, converts the first three components of the normalized floating-point value v into 10-bit unsigned integer values. 417 /// Then, converts the forth component of the normalized floating-point value v into 2-bit signed uninteger values. 418 /// Then, the results are packed into the returned 32-bit unsigned integer. 419 /// 420 /// The conversion for component c of v to fixed point is done as follows: 421 /// packUnorm3x10_1x2(xyz): round(clamp(c, 0, +1) * 1023.0) 422 /// packUnorm3x10_1x2(w): round(clamp(c, 0, +1) * 3.0) 423 /// 424 /// The first vector component specifies the 10 least-significant bits of the result; 425 /// the forth component specifies the 2 most-significant bits. 426 /// 427 /// @see gtc_packing 428 /// @see vec4 unpackUnorm3x10_1x2(uint32 const & p) 429 /// @see uint32 packUnorm3x10_1x2(vec4 const & v) 430 /// @see uint32 packU3x10_1x2(uvec4 const & v) 431 /// @see uint32 packI3x10_1x2(ivec4 const & v) 432 GLM_FUNC_DECL uint32 packUnorm3x10_1x2(vec4 const & v); 433 434 /// First, unpacks a single 32-bit unsigned integer p into four 16-bit signed integers. 435 /// Then, each component is converted to a normalized floating-point value to generate the returned four-component vector. 436 /// 437 /// The conversion for unpacked fixed-point value f to floating point is done as follows: 438 /// unpackSnorm3x10_1x2(xyz): clamp(f / 1023.0, 0, +1) 439 /// unpackSnorm3x10_1x2(w): clamp(f / 3.0, 0, +1) 440 /// 441 /// The first component of the returned vector will be extracted from the least significant bits of the input; 442 /// the last component will be extracted from the most significant bits. 443 /// 444 /// @see gtc_packing 445 /// @see uint32 packSnorm3x10_1x2(vec4 const & v) 446 /// @see vec4 unpackInorm3x10_1x2(uint32 const & p)) 447 /// @see uvec4 unpackI3x10_1x2(uint32 const & p) 448 /// @see uvec4 unpackU3x10_1x2(uint32 const & p) 449 GLM_FUNC_DECL vec4 unpackUnorm3x10_1x2(uint32 const & p); 450 451 /// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values. 452 /// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value. 453 /// Then, the results are packed into the returned 32-bit unsigned integer. 454 /// 455 /// The first vector component specifies the 11 least-significant bits of the result; 456 /// the last component specifies the 10 most-significant bits. 457 /// 458 /// @see gtc_packing 459 /// @see vec3 unpackF2x11_1x10(uint32 const & p) 460 GLM_FUNC_DECL uint32 packF2x11_1x10(vec3 const & v); 461 462 /// 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 . 463 /// Then, each component is converted to a normalized floating-point value to generate the returned three-component vector. 464 /// 465 /// The first component of the returned vector will be extracted from the least significant bits of the input; 466 /// the last component will be extracted from the most significant bits. 467 /// 468 /// @see gtc_packing 469 /// @see uint32 packF2x11_1x10(vec3 const & v) 470 GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 const & p); 471 472 /// @} 473 }// namespace glm 474 475 #include "packing.inl" 476 477 #endif//GLM_GTC_packing 478 479