diff --git a/glm/core/func_common.inl b/glm/core/func_common.inl index f075f209..b97d89a6 100644 --- a/glm/core/func_common.inl +++ b/glm/core/func_common.inl @@ -804,20 +804,21 @@ namespace detail } template - GLM_FUNC_QUALIFIER typename genType::bool_type isnan - ( - genType const & x - ) + GLM_FUNC_QUALIFIER bool isnan(genType const & x) { - GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); + GLM_STATIC_ASSERT(detail::type::is_float, "'isnan' only accept floating-point inputs"); -#if(GLM_COMPILER & GLM_COMPILER_VC) - return typename genType::bool_type(_isnan(x)); -#elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID) - return typename genType::bool_type(::isnanf(x)); -#else - return typename genType::bool_type(std::isnan(x)); -#endif +# if(GLM_COMPILER & GLM_COMPILER_VC) + return _isnan(x); +# elif(GLM_COMPILER & GLM_COMPILER_GCC) +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) + return _isnan(x) != 0; +# else + return std::isnan(x) != 0; +# endif +# else + return std::isnan(x) != 0; +# endif } template @@ -857,20 +858,22 @@ namespace detail } template - GLM_FUNC_QUALIFIER typename genType::bool_type isinf - ( - genType const & x - ) + GLM_FUNC_QUALIFIER bool isinf( + genType const & x) { GLM_STATIC_ASSERT(detail::type::is_float, "'isinf' only accept floating-point inputs"); -#if(GLM_COMPILER & GLM_COMPILER_VC) - return typename genType::bool_type(_fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF); -#elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID) - return typename genType::bool_type(::__isinf(x)); -#else - return typename genType::bool_type(std::isinf(x)); -#endif +# if(GLM_COMPILER & GLM_COMPILER_VC) + return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; +# elif(GLM_COMPILER & GLM_COMPILER_GCC) +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) + return _isinf(x) != 0; +# else + return std::isinf(x) != 0; +# endif +# else + return std::isinf(x) != 0; +# endif } template diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 13c5b722..314a27d2 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -58,7 +58,7 @@ # define GLM_PLATFORM GLM_PLATFORM_WINDOWS #elif defined(__native_client__) # define GLM_PLATFORM GLM_PLATFORM_CHROME_NACL -#elif defined(ANDROID) +#elif defined(__ANDROID__) # define GLM_PLATFORM GLM_PLATFORM_ANDROID #elif defined(__linux) # define GLM_PLATFORM GLM_PLATFORM_LINUX diff --git a/glm/gtx/compatibility.hpp b/glm/gtx/compatibility.hpp index 94223860..4c414d1b 100644 --- a/glm/gtx/compatibility.hpp +++ b/glm/gtx/compatibility.hpp @@ -87,16 +87,6 @@ namespace glm template detail::tvec3 isfinite(const detail::tvec3& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) template detail::tvec4 isfinite(const detail::tvec4& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) - template bool isinf(genType const & x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension) - template detail::tvec2 isinf(const detail::tvec2& x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension) - template detail::tvec3 isinf(const detail::tvec3& x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension) - template detail::tvec4 isinf(const detail::tvec4& x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension) - - template bool isnan(genType const & x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension) - template detail::tvec2 isnan(const detail::tvec2& x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension) - template detail::tvec3 isnan(const detail::tvec3& x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension) - template detail::tvec4 isnan(const detail::tvec4& x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension) - typedef bool bool1; //!< \brief boolean type with 1 component. (From GLM_GTX_compatibility extension) typedef detail::tvec2 bool2; //!< \brief boolean type with 2 components. (From GLM_GTX_compatibility extension) typedef detail::tvec3 bool3; //!< \brief boolean type with 3 components. (From GLM_GTX_compatibility extension) diff --git a/glm/gtx/compatibility.inl b/glm/gtx/compatibility.inl index beb8615d..cabd5c75 100644 --- a/glm/gtx/compatibility.inl +++ b/glm/gtx/compatibility.inl @@ -58,98 +58,4 @@ namespace glm isfinite(x.w)); } - // isinf - template - GLM_FUNC_QUALIFIER bool isinf( - genType const & x) - { -# if(GLM_COMPILER & GLM_COMPILER_VC) - return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; -# elif(GLM_COMPILER & GLM_COMPILER_GCC) -# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) - return _isinf(x) != 0; -# else - return std::isinf(x) != 0; -# endif -# else - return std::isinf(x) != 0; -# endif - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 isinf( - detail::tvec2 const & x) - { - return detail::tvec2( - isinf(x.x), - isinf(x.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 isinf( - detail::tvec3 const & x) - { - return detail::tvec3( - isinf(x.x), - isinf(x.y), - isinf(x.z)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 isinf( - detail::tvec4 const & x) - { - return detail::tvec4( - isinf(x.x), - isinf(x.y), - isinf(x.z), - isinf(x.w)); - } - - // isnan - template - GLM_FUNC_QUALIFIER bool isnan(genType const & x) - { -# if(GLM_COMPILER & GLM_COMPILER_VC) - return _isnan(x); -# elif(GLM_COMPILER & GLM_COMPILER_GCC) -# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) - return _isnan(x) != 0; -# else - return std::isnan(x) != 0; -# endif -# else - return std::isnan(x) != 0; -# endif - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 isnan( - detail::tvec2 const & x) - { - return detail::tvec2( - isnan(x.x), - isnan(x.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 isnan( - detail::tvec3 const & x) - { - return detail::tvec3( - isnan(x.x), - isnan(x.y), - isnan(x.z)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 isnan( - detail::tvec4 const & x) - { - return detail::tvec4( - isnan(x.x), - isnan(x.y), - isnan(x.z), - isnan(x.w)); - } }//namespace glm diff --git a/glm/virtrev/xstream.hpp b/glm/virtrev/xstream.hpp index b056a7f6..7ef6bb97 100644 --- a/glm/virtrev/xstream.hpp +++ b/glm/virtrev/xstream.hpp @@ -47,7 +47,8 @@ # pragma message("GLM: GLM_VIRTREV_xstream extension included") #endif -namespace glm +namespace glm{ +namespace detail { template std::ostream & operator << (std::ostream & stream, glm::detail::tvec2 const & vec) @@ -159,6 +160,7 @@ namespace glm return stream; } +}//namespace detail }//namespace glm #endif//GLM_VIRTREV_xstream diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index fd22dc7f..f0e22e69 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -352,6 +352,62 @@ int test_roundEven() return Error; } +int test_isnan() +{ + int Error = 0; + + float Zero_f = 0.0; + double Zero_d = 0.0; + + { + Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::dvec2(0.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::dvec3(0.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::dvec4(0.0f/Zero_f))) ? 0 : 1; + } + + { + Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1; + } + + return Error; +} + +int test_isinf() +{ + int Error = 0; + + float Zero_f = 0.0; + double Zero_d = 0.0; + + { + Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1; + Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1; + } + + { + Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1; + Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1; + } + + return Error; +} + int main() { int Error(0); @@ -362,6 +418,8 @@ int main() Error += test_mix(); Error += test_round(); Error += test_roundEven(); + Error += test_isnan(); + Error += test_isinf(); return Error; } diff --git a/test/core/core_func_swizzle.cpp b/test/core/core_func_swizzle.cpp index 0a86ba71..f36cc563 100644 --- a/test/core/core_func_swizzle.cpp +++ b/test/core/core_func_swizzle.cpp @@ -7,11 +7,21 @@ // File : test/core/core_func_swizzle.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// -#define GLM_FORCE_ONLY_XYZW -//#define GLM_FORCE_PURE -#define GLM_MESSAGES -#define GLM_SWIZZLE -#define GLM_FORCE_CXX98 +#ifndef GLM_FORCE_ONLY_XYZW +# define GLM_FORCE_ONLY_XYZW +#endif +//#ifndef GLM_FORCE_PURE +//# define GLM_FORCE_PURE +//#endif +#ifndef GLM_MESSAGES +# define GLM_MESSAGES +#endif +#ifndef GLM_SWIZZLE +# define GLM_SWIZZLE +#endif +#ifndef GLM_FORCE_CXX98 +# define GLM_FORCE_CXX98 +#endif #include int test_vec2_swizzle() diff --git a/test/gtx/gtx_integer.cpp b/test/gtx/gtx_integer.cpp index 9c97e7a5..46832c6a 100644 --- a/test/gtx/gtx_integer.cpp +++ b/test/gtx/gtx_integer.cpp @@ -53,8 +53,8 @@ int test_nlz() { int Error = 0; - for(std::size_t i = 1; i < 33; ++i) - Error += glm::nlz(i) == 31u - glm::findMSB(i) ? 0 : 1; + for(glm::uint i = 1; i < glm::uint(33); ++i) + Error += glm::nlz(i) == glm::uint(31u) - glm::findMSB(i) ? 0 : 1; //printf("%d, %d\n", glm::nlz(i), 31u - glm::findMSB(i)); return Error;