diff --git a/glm/ext.hpp b/glm/ext.hpp index 1297bda5..1f74f3cb 100644 --- a/glm/ext.hpp +++ b/glm/ext.hpp @@ -13,6 +13,7 @@ # pragma message("GLM: All extensions included (not recommended)") #endif//GLM_MESSAGES +#include "./ext/vec1.hpp" #include "./ext/vector_relational.hpp" #include "./gtc/bitfield.hpp" diff --git a/glm/ext/vec1.hpp b/glm/ext/vec1.hpp index cbaf672c..887877e5 100644 --- a/glm/ext/vec1.hpp +++ b/glm/ext/vec1.hpp @@ -390,6 +390,69 @@ namespace glm template using tvec1 = vec<1, T, Q>; #endif//GLM_HAS_TEMPLATE_ALIASES + ////////////////////////// + // vec1 definition + +#if(defined(GLM_PRECISION_HIGHP_BOOL)) + typedef highp_bvec1 bvec1; +#elif(defined(GLM_PRECISION_MEDIUMP_BOOL)) + typedef mediump_bvec1 bvec1; +#elif(defined(GLM_PRECISION_LOWP_BOOL)) + typedef lowp_bvec1 bvec1; +#else + /// 1 component vector of boolean. + /// @see gtc_vec1 extension. + typedef highp_bvec1 bvec1; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_HIGHP_FLOAT)) + typedef highp_vec1 vec1; +#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT)) + typedef mediump_vec1 vec1; +#elif(defined(GLM_PRECISION_LOWP_FLOAT)) + typedef lowp_vec1 vec1; +#else + /// 1 component vector of floating-point numbers. + /// @see gtc_vec1 extension. + typedef highp_vec1 vec1; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_HIGHP_DOUBLE)) + typedef highp_dvec1 dvec1; +#elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE)) + typedef mediump_dvec1 dvec1; +#elif(defined(GLM_PRECISION_LOWP_DOUBLE)) + typedef lowp_dvec1 dvec1; +#else + /// 1 component vector of floating-point numbers. + /// @see gtc_vec1 extension. + typedef highp_dvec1 dvec1; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_HIGHP_INT)) + typedef highp_ivec1 ivec1; +#elif(defined(GLM_PRECISION_MEDIUMP_INT)) + typedef mediump_ivec1 ivec1; +#elif(defined(GLM_PRECISION_LOWP_INT)) + typedef lowp_ivec1 ivec1; +#else + /// 1 component vector of signed integer numbers. + /// @see gtc_vec1 extension. + typedef highp_ivec1 ivec1; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_HIGHP_UINT)) + typedef highp_uvec1 uvec1; +#elif(defined(GLM_PRECISION_MEDIUMP_UINT)) + typedef mediump_uvec1 uvec1; +#elif(defined(GLM_PRECISION_LOWP_UINT)) + typedef lowp_uvec1 uvec1; +#else + /// 1 component vector of unsigned integer numbers. + /// @see gtc_vec1 extension. + typedef highp_uvec1 uvec1; +#endif//GLM_PRECISION + /// @} }//namespace glm diff --git a/glm/ext/vector_relational.hpp b/glm/ext/vector_relational.hpp index 350ed0d9..e5cfa946 100644 --- a/glm/ext/vector_relational.hpp +++ b/glm/ext/vector_relational.hpp @@ -87,26 +87,6 @@ namespace glm template GLM_FUNC_DECL bool notEqual(genType const& x, genType const& y, genType const& epsilon); - /// Returns whether vector components values are within an interval. A open interval excludes its endpoints, and is denoted with square brackets. - /// - /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector - /// @tparam T Floating-point or integer scalar types - /// @tparam Q Value from qualifier enum - /// - /// @see ext_vector_relational - template - GLM_FUNC_DECL vec openBounded(vec const& Value, vec const& Min, vec const& Max); - - /// Returns whether vector components values are within an interval. A closed interval includes its endpoints, and is denoted with square brackets. - /// - /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector - /// @tparam T Floating-point or integer scalar types - /// @tparam Q Value from qualifier enum - /// - /// @see ext_vector_relational - template - GLM_FUNC_DECL vec closeBounded(vec const& Value, vec const& Min, vec const& Max); - /// @} }//namespace glm diff --git a/glm/ext/vector_relational.inl b/glm/ext/vector_relational.inl index 3280dde4..8532a022 100644 --- a/glm/ext/vector_relational.inl +++ b/glm/ext/vector_relational.inl @@ -43,16 +43,4 @@ namespace glm { return greaterThanEqual(abs(x - y), epsilon); } - - template - GLM_FUNC_QUALIFIER vec openBounded(vec const& Value, vec const& Min, vec const& Max) - { - return greaterThan(Value, Min) && lessThan(Value, Max); - } - - template - GLM_FUNC_QUALIFIER vec closeBounded(vec const& Value, vec const& Min, vec const& Max) - { - return greaterThanEqual(Value, Min) && lessThanEqual(Value, Max); - } }//namespace glm diff --git a/glm/glm.hpp b/glm/glm.hpp index d21749da..cfd0ce27 100644 --- a/glm/glm.hpp +++ b/glm/glm.hpp @@ -49,11 +49,20 @@ /// /// @ingroup core /// -/// @defgroup gtc Stable extensions +/// @defgroup ext Stable extensions /// /// @brief Additional features not specified by GLSL specification. /// -/// GTC extensions aim to be stable. +/// EXT extensions are fully tested and documented. +/// +/// Even if it's highly unrecommended, it's possible to include all the extensions at once by +/// including . Otherwise, each extension needs to be included a specific file. +/// +/// @defgroup gtc Recommended extensions +/// +/// @brief Additional features not specified by GLSL specification. +/// +/// GTC extensions aim to be stable with tests and documentation. /// /// Even if it's highly unrecommended, it's possible to include all the extensions at once by /// including . Otherwise, each extension needs to be included a specific file. diff --git a/glm/gtc/vec1.hpp b/glm/gtc/vec1.hpp index dfe200a9..44da3abd 100644 --- a/glm/gtc/vec1.hpp +++ b/glm/gtc/vec1.hpp @@ -19,71 +19,4 @@ # pragma message("GLM: GLM_GTC_vec1 extension included") #endif -namespace glm -{ - ////////////////////////// - // vec1 definition - -#if(defined(GLM_PRECISION_HIGHP_BOOL)) - typedef highp_bvec1 bvec1; -#elif(defined(GLM_PRECISION_MEDIUMP_BOOL)) - typedef mediump_bvec1 bvec1; -#elif(defined(GLM_PRECISION_LOWP_BOOL)) - typedef lowp_bvec1 bvec1; -#else - /// 1 component vector of boolean. - /// @see gtc_vec1 extension. - typedef highp_bvec1 bvec1; -#endif//GLM_PRECISION - -#if(defined(GLM_PRECISION_HIGHP_FLOAT)) - typedef highp_vec1 vec1; -#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT)) - typedef mediump_vec1 vec1; -#elif(defined(GLM_PRECISION_LOWP_FLOAT)) - typedef lowp_vec1 vec1; -#else - /// 1 component vector of floating-point numbers. - /// @see gtc_vec1 extension. - typedef highp_vec1 vec1; -#endif//GLM_PRECISION - -#if(defined(GLM_PRECISION_HIGHP_DOUBLE)) - typedef highp_dvec1 dvec1; -#elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE)) - typedef mediump_dvec1 dvec1; -#elif(defined(GLM_PRECISION_LOWP_DOUBLE)) - typedef lowp_dvec1 dvec1; -#else - /// 1 component vector of floating-point numbers. - /// @see gtc_vec1 extension. - typedef highp_dvec1 dvec1; -#endif//GLM_PRECISION - -#if(defined(GLM_PRECISION_HIGHP_INT)) - typedef highp_ivec1 ivec1; -#elif(defined(GLM_PRECISION_MEDIUMP_INT)) - typedef mediump_ivec1 ivec1; -#elif(defined(GLM_PRECISION_LOWP_INT)) - typedef lowp_ivec1 ivec1; -#else - /// 1 component vector of signed integer numbers. - /// @see gtc_vec1 extension. - typedef highp_ivec1 ivec1; -#endif//GLM_PRECISION - -#if(defined(GLM_PRECISION_HIGHP_UINT)) - typedef highp_uvec1 uvec1; -#elif(defined(GLM_PRECISION_MEDIUMP_UINT)) - typedef mediump_uvec1 uvec1; -#elif(defined(GLM_PRECISION_LOWP_UINT)) - typedef lowp_uvec1 uvec1; -#else - /// 1 component vector of unsigned integer numbers. - /// @see gtc_vec1 extension. - typedef highp_uvec1 uvec1; -#endif//GLM_PRECISION - -}// namespace glm - #include "vec1.inl" diff --git a/glm/gtx/common.hpp b/glm/gtx/common.hpp index e73580e8..6eadf48c 100644 --- a/glm/gtx/common.hpp +++ b/glm/gtx/common.hpp @@ -50,6 +50,26 @@ namespace glm template GLM_FUNC_DECL vec fmod(vec const& v); + /// Returns whether vector components values are within an interval. A open interval excludes its endpoints, and is denoted with square brackets. + /// + /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector + /// @tparam T Floating-point or integer scalar types + /// @tparam Q Value from qualifier enum + /// + /// @see ext_vector_relational + template + GLM_FUNC_DECL vec openBounded(vec const& Value, vec const& Min, vec const& Max); + + /// Returns whether vector components values are within an interval. A closed interval includes its endpoints, and is denoted with square brackets. + /// + /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector + /// @tparam T Floating-point or integer scalar types + /// @tparam Q Value from qualifier enum + /// + /// @see ext_vector_relational + template + GLM_FUNC_DECL vec closeBounded(vec const& Value, vec const& Min, vec const& Max); + /// @} }//namespace glm diff --git a/glm/gtx/common.inl b/glm/gtx/common.inl index 856cb853..158eabe4 100644 --- a/glm/gtx/common.inl +++ b/glm/gtx/common.inl @@ -111,4 +111,16 @@ namespace detail { return detail::compute_fmod::is_iec559>::call(x, y); } + + template + GLM_FUNC_QUALIFIER vec openBounded(vec const& Value, vec const& Min, vec const& Max) + { + return greaterThan(Value, Min) && lessThan(Value, Max); + } + + template + GLM_FUNC_QUALIFIER vec closeBounded(vec const& Value, vec const& Min, vec const& Max) + { + return greaterThanEqual(Value, Min) && lessThanEqual(Value, Max); + } }//namespace glm diff --git a/glm/gtx/easing.hpp b/glm/gtx/easing.hpp index ec285e4d..b1cd326c 100644 --- a/glm/gtx/easing.hpp +++ b/glm/gtx/easing.hpp @@ -200,14 +200,17 @@ namespace glm{ template GLM_FUNC_DECL genType backEaseInOut(genType const& a, genType const& o); + /// @see gtx_easing template GLM_FUNC_DECL genType bounceEaseIn(genType const& a); + /// @see gtx_easing template GLM_FUNC_DECL genType bounceEaseOut(genType const& a); + /// @see gtx_easing template - GLM_FUNC_DECL genType bounceEaseInOut(genType const& a, genType); + GLM_FUNC_DECL genType bounceEaseInOut(genType const& a); /// @} }//namespace glm diff --git a/test/ext/ext_vec1.cpp b/test/ext/ext_vec1.cpp index 04ca86ce..0ddb10aa 100644 --- a/test/ext/ext_vec1.cpp +++ b/test/ext/ext_vec1.cpp @@ -1,8 +1,148 @@ +#define GLM_FORCE_SWIZZLE +#include #include +#include + +static glm::vec1 g1; +static glm::vec1 g2(1); + +int test_vec1_operators() +{ + int Error(0); + + glm::vec1 A(1.0f); + glm::vec1 B(1.0f); + { + bool R = A != B; + bool S = A == B; + + Error += (S && !R) ? 0 : 1; + } + + { + A *= 1.0f; + B *= 1.0; + A += 1.0f; + B += 1.0; + + bool R = A != B; + bool S = A == B; + + Error += (S && !R) ? 0 : 1; + } + + return Error; +} + +int test_vec1_ctor() +{ + int Error = 0; + +# if GLM_HAS_TRIVIAL_QUERIES + // Error += std::is_trivially_default_constructible::value ? 0 : 1; + // Error += std::is_trivially_copy_assignable::value ? 0 : 1; + Error += std::is_trivially_copyable::value ? 0 : 1; + Error += std::is_trivially_copyable::value ? 0 : 1; + Error += std::is_trivially_copyable::value ? 0 : 1; + Error += std::is_trivially_copyable::value ? 0 : 1; + + Error += std::is_copy_constructible::value ? 0 : 1; +# endif + + + { + glm::ivec1 A = glm::vec1(2.0f); + + glm::ivec1 E(glm::dvec1(2.0)); + Error += A == E ? 0 : 1; + + glm::ivec1 F(glm::ivec1(2)); + Error += A == F ? 0 : 1; + } + + return Error; +} + +int test_vec1_size() +{ + int Error = 0; + + Error += sizeof(glm::vec1) == sizeof(glm::mediump_vec1) ? 0 : 1; + Error += 4 == sizeof(glm::mediump_vec1) ? 0 : 1; + Error += sizeof(glm::dvec1) == sizeof(glm::highp_dvec1) ? 0 : 1; + Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1; + Error += glm::vec1().length() == 1 ? 0 : 1; + Error += glm::dvec1().length() == 1 ? 0 : 1; + Error += glm::vec1::length() == 1 ? 0 : 1; + Error += glm::dvec1::length() == 1 ? 0 : 1; + +# if GLM_HAS_CONSTEXPR_PARTIAL + constexpr std::size_t Length = glm::vec1::length(); + Error += Length == 1 ? 0 : 1; +# endif + + return Error; +} + +int test_vec1_operator_increment() +{ + int Error(0); + + glm::ivec1 v0(1); + glm::ivec1 v1(v0); + glm::ivec1 v2(v0); + glm::ivec1 v3 = ++v1; + glm::ivec1 v4 = v2++; + + Error += glm::all(glm::equal(v0, v4)) ? 0 : 1; + Error += glm::all(glm::equal(v1, v2)) ? 0 : 1; + Error += glm::all(glm::equal(v1, v3)) ? 0 : 1; + + int i0(1); + int i1(i0); + int i2(i0); + int i3 = ++i1; + int i4 = i2++; + + Error += i0 == i4 ? 0 : 1; + Error += i1 == i2 ? 0 : 1; + Error += i1 == i3 ? 0 : 1; + + return Error; +} + +static int test_bvec1_ctor() +{ + int Error = 0; + + glm::bvec1 const A(true); + glm::bvec1 const B(true); + glm::bvec1 const C(false); + glm::bvec1 const D = A && B; + glm::bvec1 const E = A && C; + glm::bvec1 const F = A || C; + + Error += D == glm::bvec1(true) ? 0 : 1; + Error += E == glm::bvec1(false) ? 0 : 1; + Error += F == glm::bvec1(true) ? 0 : 1; + + bool const G = A == C; + bool const H = A != C; + Error += !G ? 0 : 1; + Error += H ? 0 : 1; + + return Error; +} int main() { int Error = 0; + Error += test_vec1_size(); + Error += test_vec1_ctor(); + Error += test_bvec1_ctor(); + Error += test_vec1_operators(); + Error += test_vec1_operator_increment(); + return Error; } diff --git a/test/ext/ext_vector_relational.cpp b/test/ext/ext_vector_relational.cpp index 44183b33..d8b19ba6 100644 --- a/test/ext/ext_vector_relational.cpp +++ b/test/ext/ext_vector_relational.cpp @@ -31,36 +31,12 @@ int test_notEqual() return Error; } -int test_openBounded() -{ - int Error = 0; - - Error += glm::all(glm::openBounded(glm::ivec2(2), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; - Error += !glm::all(glm::openBounded(glm::ivec2(1), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; - Error += !glm::all(glm::openBounded(glm::ivec2(3), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; - - return Error; -} - -int test_closeBounded() -{ - int Error = 0; - - Error += glm::all(glm::closeBounded(glm::ivec2(2), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; - Error += glm::all(glm::closeBounded(glm::ivec2(1), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; - Error += glm::all(glm::closeBounded(glm::ivec2(3), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; - - return Error; -} - int main() { int Error = 0; Error += test_equal(); Error += test_notEqual(); - Error += test_openBounded(); - Error += test_closeBounded(); return Error; } diff --git a/test/gtx/gtx_common.cpp b/test/gtx/gtx_common.cpp index 1602681b..fd4fa99b 100644 --- a/test/gtx/gtx_common.cpp +++ b/test/gtx/gtx_common.cpp @@ -126,12 +126,36 @@ int test_isdenormal() return Error; } +int test_openBounded() +{ + int Error = 0; + + Error += glm::all(glm::openBounded(glm::ivec2(2), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; + Error += !glm::all(glm::openBounded(glm::ivec2(1), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; + Error += !glm::all(glm::openBounded(glm::ivec2(3), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; + + return Error; +} + +int test_closeBounded() +{ + int Error = 0; + + Error += glm::all(glm::closeBounded(glm::ivec2(2), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; + Error += glm::all(glm::closeBounded(glm::ivec2(1), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; + Error += glm::all(glm::closeBounded(glm::ivec2(3), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1; + + return Error; +} + int main() { int Error = 0; Error += test_isdenormal(); Error += ::fmod_::test(); + Error += test_openBounded(); + Error += test_closeBounded(); return Error; }