integer.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2015 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. /// Restrictions:
  16. /// By making use of the Software for military purposes, you choose to make
  17. /// a Bunny unhappy.
  18. ///
  19. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. /// THE SOFTWARE.
  26. ///
  27. /// @ref gtc_integer
  28. /// @file glm/gtc/integer.hpp
  29. /// @date 2014-11-17 / 2014-11-17
  30. /// @author Christophe Riccio
  31. ///
  32. /// @see core (dependence)
  33. /// @see gtc_integer (dependence)
  34. ///
  35. /// @defgroup gtc_integer GLM_GTC_integer
  36. /// @ingroup gtc
  37. ///
  38. /// @brief Allow to perform bit operations on integer values
  39. ///
  40. /// <glm/gtc/integer.hpp> need to be included to use these functionalities.
  41. ///////////////////////////////////////////////////////////////////////////////////
  42. #pragma once
  43. // Dependencies
  44. #include "../detail/setup.hpp"
  45. #include "../detail/precision.hpp"
  46. #include "../detail/func_common.hpp"
  47. #include "../detail/func_integer.hpp"
  48. #include "../detail/func_exponential.hpp"
  49. #include <limits>
  50. #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
  51. # pragma message("GLM: GLM_GTC_integer extension included")
  52. #endif
  53. namespace glm
  54. {
  55. /// @addtogroup gtc_integer
  56. /// @{
  57. /// Returns the log2 of x for integer values. Can be reliably using to compute mipmap count from the texture size.
  58. /// @see gtc_integer
  59. template <typename genIUType>
  60. GLM_FUNC_DECL genIUType log2(genIUType x);
  61. /// Modulus. Returns x % y
  62. /// for each component in x using the floating point value y.
  63. ///
  64. /// @tparam genIUType Integer-point scalar or vector types.
  65. ///
  66. /// @see gtc_integer
  67. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
  68. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  69. template <typename genIUType>
  70. GLM_FUNC_DECL genIUType mod(genIUType x, genIUType y);
  71. /// Modulus. Returns x % y
  72. /// for each component in x using the floating point value y.
  73. ///
  74. /// @tparam T Integer scalar types.
  75. /// @tparam vecType vector types.
  76. ///
  77. /// @see gtc_integer
  78. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
  79. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  80. template <typename T, precision P, template <typename, precision> class vecType>
  81. GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, T y);
  82. /// Modulus. Returns x % y
  83. /// for each component in x using the floating point value y.
  84. ///
  85. /// @tparam T Integer scalar types.
  86. /// @tparam vecType vector types.
  87. ///
  88. /// @see gtc_integer
  89. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod 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.3 Common Functions</a>
  91. template <typename T, precision P, template <typename, precision> class vecType>
  92. GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, vecType<T, P> const & y);
  93. /// @}
  94. } //namespace glm
  95. #include "integer.inl"