| 1 | /// @ref ext_vector_integer |
| 2 | /// @file glm/ext/vector_integer.hpp |
| 3 | /// |
| 4 | /// @see core (dependence) |
| 5 | /// @see ext_vector_integer (dependence) |
| 6 | /// |
| 7 | /// @defgroup ext_vector_integer GLM_EXT_vector_integer |
| 8 | /// @ingroup ext |
| 9 | /// |
| 10 | /// Include <glm/ext/vector_integer.hpp> to use the features of this extension. |
| 11 | |
| 12 | #pragma once |
| 13 | |
| 14 | // Dependencies |
| 15 | #include "../detail/setup.hpp" |
| 16 | #include "../detail/qualifier.hpp" |
| 17 | #include "../detail/_vectorize.hpp" |
| 18 | #include "../vector_relational.hpp" |
| 19 | #include "../common.hpp" |
| 20 | #include <limits> |
| 21 | |
| 22 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) |
| 23 | # pragma message("GLM: GLM_EXT_vector_integer extension included") |
| 24 | #endif |
| 25 | |
| 26 | namespace glm |
| 27 | { |
| 28 | /// @addtogroup ext_vector_integer |
| 29 | /// @{ |
| 30 | |
| 31 | /// Return true if the value is a power of two number. |
| 32 | /// |
| 33 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 34 | /// @tparam T Signed or unsigned integer scalar types. |
| 35 | /// @tparam Q Value from qualifier enum |
| 36 | /// |
| 37 | /// @see ext_vector_integer |
| 38 | template<length_t L, typename T, qualifier Q> |
| 39 | GLM_FUNC_DECL vec<L, bool, Q> isPowerOfTwo(vec<L, T, Q> const& v); |
| 40 | |
| 41 | /// Return the power of two number which value is just higher the input value, |
| 42 | /// round up to a power of two. |
| 43 | /// |
| 44 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 45 | /// @tparam T Signed or unsigned integer scalar types. |
| 46 | /// @tparam Q Value from qualifier enum |
| 47 | /// |
| 48 | /// @see ext_vector_integer |
| 49 | template<length_t L, typename T, qualifier Q> |
| 50 | GLM_FUNC_DECL vec<L, T, Q> nextPowerOfTwo(vec<L, T, Q> const& v); |
| 51 | |
| 52 | /// Return the power of two number which value is just lower the input value, |
| 53 | /// round down to a power of two. |
| 54 | /// |
| 55 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 56 | /// @tparam T Signed or unsigned integer scalar types. |
| 57 | /// @tparam Q Value from qualifier enum |
| 58 | /// |
| 59 | /// @see ext_vector_integer |
| 60 | template<length_t L, typename T, qualifier Q> |
| 61 | GLM_FUNC_DECL vec<L, T, Q> prevPowerOfTwo(vec<L, T, Q> const& v); |
| 62 | |
| 63 | /// Return true if the 'Value' is a multiple of 'Multiple'. |
| 64 | /// |
| 65 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 66 | /// @tparam T Signed or unsigned integer scalar types. |
| 67 | /// @tparam Q Value from qualifier enum |
| 68 | /// |
| 69 | /// @see ext_vector_integer |
| 70 | template<length_t L, typename T, qualifier Q> |
| 71 | GLM_FUNC_DECL vec<L, bool, Q> isMultiple(vec<L, T, Q> const& v, T Multiple); |
| 72 | |
| 73 | /// Return true if the 'Value' is a multiple of 'Multiple'. |
| 74 | /// |
| 75 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 76 | /// @tparam T Signed or unsigned integer scalar types. |
| 77 | /// @tparam Q Value from qualifier enum |
| 78 | /// |
| 79 | /// @see ext_vector_integer |
| 80 | template<length_t L, typename T, qualifier Q> |
| 81 | GLM_FUNC_DECL vec<L, bool, Q> isMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple); |
| 82 | |
| 83 | /// Higher multiple number of Source. |
| 84 | /// |
| 85 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 86 | /// @tparam T Signed or unsigned integer scalar types. |
| 87 | /// @tparam Q Value from qualifier enum |
| 88 | /// |
| 89 | /// @param v Source values to which is applied the function |
| 90 | /// @param Multiple Must be a null or positive value |
| 91 | /// |
| 92 | /// @see ext_vector_integer |
| 93 | template<length_t L, typename T, qualifier Q> |
| 94 | GLM_FUNC_DECL vec<L, T, Q> nextMultiple(vec<L, T, Q> const& v, T Multiple); |
| 95 | |
| 96 | /// Higher multiple number of Source. |
| 97 | /// |
| 98 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 99 | /// @tparam T Signed or unsigned integer scalar types. |
| 100 | /// @tparam Q Value from qualifier enum |
| 101 | /// |
| 102 | /// @param v Source values to which is applied the function |
| 103 | /// @param Multiple Must be a null or positive value |
| 104 | /// |
| 105 | /// @see ext_vector_integer |
| 106 | template<length_t L, typename T, qualifier Q> |
| 107 | GLM_FUNC_DECL vec<L, T, Q> nextMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple); |
| 108 | |
| 109 | /// Lower multiple number of Source. |
| 110 | /// |
| 111 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 112 | /// @tparam T Signed or unsigned integer scalar types. |
| 113 | /// @tparam Q Value from qualifier enum |
| 114 | /// |
| 115 | /// @param v Source values to which is applied the function |
| 116 | /// @param Multiple Must be a null or positive value |
| 117 | /// |
| 118 | /// @see ext_vector_integer |
| 119 | template<length_t L, typename T, qualifier Q> |
| 120 | GLM_FUNC_DECL vec<L, T, Q> prevMultiple(vec<L, T, Q> const& v, T Multiple); |
| 121 | |
| 122 | /// Lower multiple number of Source. |
| 123 | /// |
| 124 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 125 | /// @tparam T Signed or unsigned integer scalar types. |
| 126 | /// @tparam Q Value from qualifier enum |
| 127 | /// |
| 128 | /// @param v Source values to which is applied the function |
| 129 | /// @param Multiple Must be a null or positive value |
| 130 | /// |
| 131 | /// @see ext_vector_integer |
| 132 | template<length_t L, typename T, qualifier Q> |
| 133 | GLM_FUNC_DECL vec<L, T, Q> prevMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple); |
| 134 | |
| 135 | /// Returns the bit number of the Nth significant bit set to |
| 136 | /// 1 in the binary representation of value. |
| 137 | /// If value bitcount is less than the Nth significant bit, -1 will be returned. |
| 138 | /// |
| 139 | /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. |
| 140 | /// @tparam T Signed or unsigned integer scalar types. |
| 141 | /// |
| 142 | /// @see ext_vector_integer |
| 143 | template<length_t L, typename T, qualifier Q> |
| 144 | GLM_FUNC_DECL vec<L, int, Q> findNSB(vec<L, T, Q> const& Source, vec<L, int, Q> SignificantBitCount); |
| 145 | |
| 146 | /// @} |
| 147 | } //namespace glm |
| 148 | |
| 149 | #include "vector_integer.inl" |