Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
10KB

  1. /// @ref core
  2. /// @file glm/packing.hpp
  3. ///
  4. /// @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>
  5. /// @see gtc_packing
  6. ///
  7. /// @defgroup core_func_packing Floating-Point Pack and Unpack Functions
  8. /// @ingroup core
  9. ///
  10. /// Include <glm/packing.hpp> to use these core features.
  11. ///
  12. /// These functions do not operate component-wise, rather as described in each case.
  13. #pragma once
  14. #include "detail/type_vec2.hpp"
  15. #include "detail/type_vec4.hpp"
  16. namespace glm
  17. {
  18. /// @addtogroup core_func_packing
  19. /// @{
  20. /// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
  21. /// Then, the results are packed into the returned 32-bit unsigned integer.
  22. ///
  23. /// The conversion for component c of v to fixed point is done as follows:
  24. /// packUnorm2x16: round(clamp(c, 0, +1) * 65535.0)
  25. ///
  26. /// The first component of the vector will be written to the least significant bits of the output;
  27. /// the last component will be written to the most significant bits.
  28. ///
  29. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm2x16.xml">GLSL packUnorm2x16 man page</a>
  30. /// @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>
  31. GLM_FUNC_DECL uint packUnorm2x16(vec2 const& v);
  32. /// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
  33. /// Then, the results are packed into the returned 32-bit unsigned integer.
  34. ///
  35. /// The conversion for component c of v to fixed point is done as follows:
  36. /// packSnorm2x16: round(clamp(v, -1, +1) * 32767.0)
  37. ///
  38. /// The first component of the vector will be written to the least significant bits of the output;
  39. /// the last component will be written to the most significant bits.
  40. ///
  41. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm2x16.xml">GLSL packSnorm2x16 man page</a>
  42. /// @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>
  43. GLM_FUNC_DECL uint packSnorm2x16(vec2 const& v);
  44. /// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
  45. /// Then, the results are packed into the returned 32-bit unsigned integer.
  46. ///
  47. /// The conversion for component c of v to fixed point is done as follows:
  48. /// packUnorm4x8: round(clamp(c, 0, +1) * 255.0)
  49. ///
  50. /// The first component of the vector will be written to the least significant bits of the output;
  51. /// the last component will be written to the most significant bits.
  52. ///
  53. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
  54. /// @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>
  55. GLM_FUNC_DECL uint packUnorm4x8(vec4 const& v);
  56. /// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
  57. /// Then, the results are packed into the returned 32-bit unsigned integer.
  58. ///
  59. /// The conversion for component c of v to fixed point is done as follows:
  60. /// packSnorm4x8: round(clamp(c, -1, +1) * 127.0)
  61. ///
  62. /// The first component of the vector will be written to the least significant bits of the output;
  63. /// the last component will be written to the most significant bits.
  64. ///
  65. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 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 uint packSnorm4x8(vec4 const& v);
  68. /// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
  69. /// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
  70. ///
  71. /// The conversion for unpacked fixed-point value f to floating point is done as follows:
  72. /// unpackUnorm2x16: f / 65535.0
  73. ///
  74. /// The first component of the returned vector will be extracted from the least significant bits of the input;
  75. /// the last component will be extracted from the most significant bits.
  76. ///
  77. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
  78. /// @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>
  79. GLM_FUNC_DECL vec2 unpackUnorm2x16(uint p);
  80. /// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
  81. /// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
  82. ///
  83. /// The conversion for unpacked fixed-point value f to floating point is done as follows:
  84. /// unpackSnorm2x16: clamp(f / 32767.0, -1, +1)
  85. ///
  86. /// The first component of the returned vector will be extracted from the least significant bits of the input;
  87. /// the last component will be extracted from the most significant bits.
  88. ///
  89. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm2x16.xml">GLSL unpackSnorm2x16 man page</a>
  90. /// @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>
  91. GLM_FUNC_DECL vec2 unpackSnorm2x16(uint p);
  92. /// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
  93. /// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
  94. ///
  95. /// The conversion for unpacked fixed-point value f to floating point is done as follows:
  96. /// unpackUnorm4x8: f / 255.0
  97. ///
  98. /// The first component of the returned vector will be extracted from the least significant bits of the input;
  99. /// the last component will be extracted from the most significant bits.
  100. ///
  101. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
  102. /// @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>
  103. GLM_FUNC_DECL vec4 unpackUnorm4x8(uint p);
  104. /// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
  105. /// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
  106. ///
  107. /// The conversion for unpacked fixed-point value f to floating point is done as follows:
  108. /// unpackSnorm4x8: clamp(f / 127.0, -1, +1)
  109. ///
  110. /// The first component of the returned vector will be extracted from the least significant bits of the input;
  111. /// the last component will be extracted from the most significant bits.
  112. ///
  113. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
  114. /// @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>
  115. GLM_FUNC_DECL vec4 unpackSnorm4x8(uint p);
  116. /// Returns a double-qualifier value obtained by packing the components of v into a 64-bit value.
  117. /// If an IEEE 754 Inf or NaN is created, it will not signal, and the resulting floating point value is unspecified.
  118. /// Otherwise, the bit- level representation of v is preserved.
  119. /// The first vector component specifies the 32 least significant bits;
  120. /// the second component specifies the 32 most significant bits.
  121. ///
  122. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packDouble2x32.xml">GLSL packDouble2x32 man page</a>
  123. /// @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>
  124. GLM_FUNC_DECL double packDouble2x32(uvec2 const& v);
  125. /// Returns a two-component unsigned integer vector representation of v.
  126. /// The bit-level representation of v is preserved.
  127. /// The first component of the vector contains the 32 least significant bits of the double;
  128. /// the second component consists the 32 most significant bits.
  129. ///
  130. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackDouble2x32.xml">GLSL unpackDouble2x32 man page</a>
  131. /// @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>
  132. GLM_FUNC_DECL uvec2 unpackDouble2x32(double v);
  133. /// Returns an unsigned integer obtained by converting the components of a two-component floating-point vector
  134. /// to the 16-bit floating-point representation found in the OpenGL Specification,
  135. /// and then packing these two 16- bit integers into a 32-bit unsigned integer.
  136. /// The first vector component specifies the 16 least-significant bits of the result;
  137. /// the second component specifies the 16 most-significant bits.
  138. ///
  139. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 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 uint packHalf2x16(vec2 const& v);
  142. /// Returns a two-component floating-point vector with components obtained by unpacking a 32-bit unsigned integer into a pair of 16-bit values,
  143. /// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification,
  144. /// and converting them to 32-bit floating-point values.
  145. /// The first component of the vector is obtained from the 16 least-significant bits of v;
  146. /// the second component is obtained from the 16 most-significant bits of v.
  147. ///
  148. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
  149. /// @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>
  150. GLM_FUNC_DECL vec2 unpackHalf2x16(uint v);
  151. /// @}
  152. }//namespace glm
  153. #include "detail/func_packing.inl"