1 /// @ref gtc_integer 2 /// @file glm/gtc/integer.hpp 3 /// 4 /// @see core (dependence) 5 /// @see gtc_integer (dependence) 6 /// 7 /// @defgroup gtc_integer GLM_GTC_integer 8 /// @ingroup gtc 9 /// 10 /// @brief Allow to perform bit operations on integer values 11 /// 12 /// <glm/gtc/integer.hpp> need to be included to use these functionalities. 13 14 #pragma once 15 16 // Dependencies 17 #include "../detail/setup.hpp" 18 #include "../detail/precision.hpp" 19 #include "../detail/func_common.hpp" 20 #include "../detail/func_integer.hpp" 21 #include "../detail/func_exponential.hpp" 22 #include <limits> 23 24 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 25 # pragma message("GLM: GLM_GTC_integer extension included") 26 #endif 27 28 namespace glm 29 { 30 /// @addtogroup gtc_integer 31 /// @{ 32 33 /// Returns the log2 of x for integer values. Can be reliably using to compute mipmap count from the texture size. 34 /// @see gtc_integer 35 template <typename genIUType> 36 GLM_FUNC_DECL genIUType log2(genIUType x); 37 38 /// Modulus. Returns x % y 39 /// for each component in x using the floating point value y. 40 /// 41 /// @tparam genIUType Integer-point scalar or vector types. 42 /// 43 /// @see gtc_integer 44 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a> 45 /// @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> 46 template <typename genIUType> 47 GLM_FUNC_DECL genIUType mod(genIUType x, genIUType y); 48 49 /// Modulus. Returns x % y 50 /// for each component in x using the floating point value y. 51 /// 52 /// @tparam T Integer scalar types. 53 /// @tparam vecType vector types. 54 /// 55 /// @see gtc_integer 56 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a> 57 /// @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> 58 template <typename T, precision P, template <typename, precision> class vecType> 59 GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, T y); 60 61 /// Modulus. Returns x % y 62 /// for each component in x using the floating point value y. 63 /// 64 /// @tparam T Integer scalar types. 65 /// @tparam vecType vector types. 66 /// 67 /// @see gtc_integer 68 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a> 69 /// @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> 70 template <typename T, precision P, template <typename, precision> class vecType> 71 GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, vecType<T, P> const & y); 72 73 /// Returns a value equal to the nearest integer to x. 74 /// The fraction 0.5 will round in a direction chosen by the 75 /// implementation, presumably the direction that is fastest. 76 /// 77 /// @param x The values of the argument must be greater or equal to zero. 78 /// @tparam T floating point scalar types. 79 /// @tparam vecType vector types. 80 /// 81 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a> 82 /// @see gtc_integer 83 template <typename T, precision P, template <typename, precision> class vecType> 84 GLM_FUNC_DECL vecType<int, P> iround(vecType<T, P> const & x); 85 86 /// Returns a value equal to the nearest integer to x. 87 /// The fraction 0.5 will round in a direction chosen by the 88 /// implementation, presumably the direction that is fastest. 89 /// 90 /// @param x The values of the argument must be greater or equal to zero. 91 /// @tparam T floating point scalar types. 92 /// @tparam vecType vector types. 93 /// 94 /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a> 95 /// @see gtc_integer 96 template <typename T, precision P, template <typename, precision> class vecType> 97 GLM_FUNC_DECL vecType<uint, P> uround(vecType<T, P> const & x); 98 99 /// @} 100 } //namespace glm 101 102 #include "integer.inl" 103