scalar_common.hpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /// @ref ext_scalar_common
  2. /// @file glm/ext/scalar_common.hpp
  3. ///
  4. /// @defgroup ext_scalar_common GLM_EXT_scalar_common
  5. /// @ingroup ext
  6. ///
  7. /// Exposes min and max functions for 3 to 4 scalar parameters.
  8. ///
  9. /// Include <glm/ext/scalar_common.hpp> to use the features of this extension.
  10. ///
  11. /// @see core_func_common
  12. /// @see ext_vector_common
  13. #pragma once
  14. // Dependency:
  15. #include "../common.hpp"
  16. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  17. # pragma message("GLM: GLM_EXT_scalar_common extension included")
  18. #endif
  19. namespace glm
  20. {
  21. /// @addtogroup ext_scalar_common
  22. /// @{
  23. /// Returns the minimum component-wise values of 3 inputs
  24. ///
  25. /// @tparam T A floating-point scalar type.
  26. ///
  27. /// @see ext_scalar_common
  28. template<typename T>
  29. GLM_FUNC_DECL T (min)(T a, T b, T c);
  30. /// Returns the minimum component-wise values of 4 inputs
  31. ///
  32. /// @tparam T A floating-point scalar type.
  33. ///
  34. /// @see ext_scalar_common
  35. template<typename T>
  36. GLM_FUNC_DECL T (min)(T a, T b, T c, T d);
  37. /// Returns the maximum component-wise values of 3 inputs
  38. ///
  39. /// @tparam T A floating-point scalar type.
  40. ///
  41. /// @see ext_scalar_common
  42. template<typename T>
  43. GLM_FUNC_DECL T (max)(T a, T b, T c);
  44. /// Returns the maximum component-wise values of 4 inputs
  45. ///
  46. /// @tparam T A floating-point scalar type.
  47. ///
  48. /// @see ext_scalar_common
  49. template<typename T>
  50. GLM_FUNC_DECL T (max)(T a, T b, T c, T d);
  51. /// Returns the minimum component-wise values of 2 inputs. If one of the two arguments is NaN, the value of the other argument is returned.
  52. ///
  53. /// @tparam T A floating-point scalar type.
  54. ///
  55. /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmin">std::fmin documentation</a>
  56. /// @see ext_scalar_common
  57. template<typename T>
  58. GLM_FUNC_DECL T (fmin)(T a, T b);
  59. /// Returns the minimum component-wise values of 3 inputs. If one of the two arguments is NaN, the value of the other argument is returned.
  60. ///
  61. /// @tparam T A floating-point scalar type.
  62. ///
  63. /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmin">std::fmin documentation</a>
  64. /// @see ext_scalar_common
  65. template<typename T>
  66. GLM_FUNC_DECL T (fmin)(T a, T b, T c);
  67. /// Returns the minimum component-wise values of 4 inputs. If one of the two arguments is NaN, the value of the other argument is returned.
  68. ///
  69. /// @tparam T A floating-point scalar type.
  70. ///
  71. /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmin">std::fmin documentation</a>
  72. /// @see ext_scalar_common
  73. template<typename T>
  74. GLM_FUNC_DECL T (fmin)(T a, T b, T c, T d);
  75. /// Returns the maximum component-wise values of 2 inputs. If one of the two arguments is NaN, the value of the other argument is returned.
  76. ///
  77. /// @tparam T A floating-point scalar type.
  78. ///
  79. /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a>
  80. /// @see ext_scalar_common
  81. template<typename T>
  82. GLM_FUNC_DECL T (fmax)(T a, T b);
  83. /// Returns the maximum component-wise values of 3 inputs. If one of the two arguments is NaN, the value of the other argument is returned.
  84. ///
  85. /// @tparam T A floating-point scalar type.
  86. ///
  87. /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a>
  88. /// @see ext_scalar_common
  89. template<typename T>
  90. GLM_FUNC_DECL T (fmax)(T a, T b, T C);
  91. /// Returns the maximum component-wise values of 4 inputs. If one of the two arguments is NaN, the value of the other argument is returned.
  92. ///
  93. /// @tparam T A floating-point scalar type.
  94. ///
  95. /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a>
  96. /// @see ext_scalar_common
  97. template<typename T>
  98. GLM_FUNC_DECL T (fmax)(T a, T b, T C, T D);
  99. /// Returns min(max(x, minVal), maxVal) for each component in x. If one of the two arguments is NaN, the value of the other argument is returned.
  100. ///
  101. /// @tparam genType Floating-point scalar types.
  102. ///
  103. /// @see ext_scalar_common
  104. template<typename genType>
  105. GLM_FUNC_DECL genType fclamp(genType x, genType minVal, genType maxVal);
  106. /// Simulate GL_CLAMP OpenGL wrap mode
  107. ///
  108. /// @tparam genType Floating-point scalar types.
  109. ///
  110. /// @see ext_scalar_common extension.
  111. template<typename genType>
  112. GLM_FUNC_DECL genType clamp(genType const& Texcoord);
  113. /// Simulate GL_REPEAT OpenGL wrap mode
  114. ///
  115. /// @tparam genType Floating-point scalar types.
  116. ///
  117. /// @see ext_scalar_common extension.
  118. template<typename genType>
  119. GLM_FUNC_DECL genType repeat(genType const& Texcoord);
  120. /// Simulate GL_MIRRORED_REPEAT OpenGL wrap mode
  121. ///
  122. /// @tparam genType Floating-point scalar types.
  123. ///
  124. /// @see ext_scalar_common extension.
  125. template<typename genType>
  126. GLM_FUNC_DECL genType mirrorClamp(genType const& Texcoord);
  127. /// Simulate GL_MIRROR_REPEAT OpenGL wrap mode
  128. ///
  129. /// @tparam genType Floating-point scalar types.
  130. ///
  131. /// @see ext_scalar_common extension.
  132. template<typename genType>
  133. GLM_FUNC_DECL genType mirrorRepeat(genType const& Texcoord);
  134. /// Returns a value equal to the nearest integer to x.
  135. /// The fraction 0.5 will round in a direction chosen by the
  136. /// implementation, presumably the direction that is fastest.
  137. ///
  138. /// @param x The values of the argument must be greater or equal to zero.
  139. /// @tparam genType floating point scalar types.
  140. ///
  141. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
  142. /// @see ext_scalar_common extension.
  143. template<typename genType>
  144. GLM_FUNC_DECL int iround(genType const& x);
  145. /// Returns a value equal to the nearest integer to x.
  146. /// The fraction 0.5 will round in a direction chosen by the
  147. /// implementation, presumably the direction that is fastest.
  148. ///
  149. /// @param x The values of the argument must be greater or equal to zero.
  150. /// @tparam genType floating point scalar types.
  151. ///
  152. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
  153. /// @see ext_scalar_common extension.
  154. template<typename genType>
  155. GLM_FUNC_DECL uint uround(genType const& x);
  156. /// @}
  157. }//namespace glm
  158. #include "scalar_common.inl"