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