diff --git a/glm/detail/func_common.hpp b/glm/detail/func_common.hpp index 7989a023..97e64ebe 100644 --- a/glm/detail/func_common.hpp +++ b/glm/detail/func_common.hpp @@ -54,23 +54,26 @@ namespace glm template GLM_FUNC_DECL genType abs(genType x); + template class vecType> + GLM_FUNC_DECL vecType abs(vecType const & x); + /// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0. /// /// @tparam genType Floating-point or signed integer; scalar or vector types. /// /// @see GLSL sign man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template - GLM_FUNC_DECL genType sign(genType x); - + template class vecType> + GLM_FUNC_DECL vecType sign(vecType const & x); + /// Returns a value equal to the nearest integer that is less then or equal to x. /// /// @tparam genType Floating-point scalar or vector types. /// /// @see GLSL floor man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template - GLM_FUNC_DECL genType floor(genType x); + template class vecType> + GLM_FUNC_DECL vecType floor(vecType const & x); /// Returns a value equal to the nearest integer to x /// whose absolute value is not larger than the absolute value of x. @@ -79,8 +82,8 @@ namespace glm /// /// @see GLSL trunc man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template - GLM_FUNC_DECL genType trunc(genType x); + template class vecType> + GLM_FUNC_DECL vecType trunc(vecType const & x); /// Returns a value equal to the nearest integer to x. /// The fraction 0.5 will round in a direction chosen by the @@ -92,9 +95,9 @@ namespace glm /// /// @see GLSL round man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template - GLM_FUNC_DECL genType round(genType x); - + template class vecType> + GLM_FUNC_DECL vecType round(vecType const & x); + /// Returns a value equal to the nearest integer to x. /// A fractional part of 0.5 will round toward the nearest even /// integer. (Both 3.5 and 4.5 for x will return 4.0.) @@ -104,8 +107,8 @@ namespace glm /// @see GLSL roundEven man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions /// @see New round to even technique - template - GLM_FUNC_DECL genType roundEven(genType x); + template class vecType> + GLM_FUNC_DECL vecType roundEven(vecType const & x); /// Returns a value equal to the nearest integer /// that is greater than or equal to x. @@ -114,8 +117,8 @@ namespace glm /// /// @see GLSL ceil man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template - GLM_FUNC_DECL genType ceil(genType x); + template class vecType> + GLM_FUNC_DECL vecType ceil(vecType const & x); /// Return x - floor(x). /// @@ -126,6 +129,9 @@ namespace glm template GLM_FUNC_DECL genType fract(genType x); + template class vecType> + GLM_FUNC_DECL vecType fract(vecType const & x); + /// Modulus. Returns x - y * floor(x / y) /// for each component in x using the floating point value y. /// diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 0bfe26e4..75159a71 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -177,7 +177,6 @@ namespace detail // floor using ::std::floor; - template class vecType> GLM_FUNC_QUALIFIER vecType floor(vecType const & x) { @@ -273,7 +272,6 @@ namespace detail // ceil using ::std::ceil; - template class vecType> GLM_FUNC_QUALIFIER vecType ceil(vecType const & x) { diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 7495c74a..78dd193a 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -517,10 +517,9 @@ ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43))) #define GLM_HAS_TEMPLATE_ALIASES ( \ - (GLM_LANG & GLM_LANG_CXX11_FLAG) || \ ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12))) || \ - ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \ __has_feature(cxx_alias_templates)) + //((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \ #define GLM_HAS_RANGE_FOR ( \ (GLM_LANG & GLM_LANG_CXX11_FLAG) || \ diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index f64ddd18..04e9b8cf 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -69,7 +69,7 @@ namespace glm # endif {} -#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) +#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4() # ifndef GLM_FORCE_NO_CTOR_INIT @@ -90,7 +90,7 @@ namespace glm : x(v.x), y(v.y), z(v.z), w(v.w) {} -#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) +#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) : data(v.data) @@ -120,7 +120,7 @@ namespace glm : x(s), y(s), z(s), w(s) {} -#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) +#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4(float const & s) : data(_mm_set1_ps(s)) @@ -137,7 +137,7 @@ namespace glm : x(a), y(b), z(c), w(d) {} -#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) +#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4(float const & a, float const & b, float const & c, float const & d) : data(_mm_set_ps(d, c, b, a)) @@ -294,7 +294,7 @@ namespace glm return *this; } -#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) +#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= (tvec4 const & v) { @@ -332,7 +332,7 @@ namespace glm return *this; } -#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) +#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) template <> template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U s) @@ -377,7 +377,7 @@ namespace glm return *this; } -#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) +#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) template <> template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & s) diff --git a/glm/gtc/random.inl b/glm/gtc/random.inl index d2131ff0..cd5d3508 100644 --- a/glm/gtc/random.inl +++ b/glm/gtc/random.inl @@ -313,7 +313,7 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType gaussRand(vecType const & Mean, vecType const & Deviation) { - return detail::functor2::call(gaussRand, Mean, Deviation); + return detail::functor2::call(gaussRand, Mean, Deviation); } template diff --git a/glm/gtx/fast_trigonometry.inl b/glm/gtx/fast_trigonometry.inl index 55c09b0c..d5d83b37 100644 --- a/glm/gtx/fast_trigonometry.inl +++ b/glm/gtx/fast_trigonometry.inl @@ -85,7 +85,7 @@ namespace glm template class vecType> GLM_FUNC_QUALIFIER vecType fastAtan(vecType const & y, vecType const & x) { - return detail::functor2::call(fastAtan, y, x); + return detail::functor2::call(fastAtan, y, x); } template diff --git a/glm/gtx/multiple.inl b/glm/gtx/multiple.inl index 949271f8..864936af 100644 --- a/glm/gtx/multiple.inl +++ b/glm/gtx/multiple.inl @@ -123,7 +123,7 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType higherMultiple(vecType const & Source, vecType const & Multiple) { - return detail::functor2::call(higherMultiple, Source, Multiple); + return detail::functor2::call(higherMultiple, Source, Multiple); } ////////////////////// @@ -138,6 +138,6 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType lowerMultiple(vecType const & Source, vecType const & Multiple) { - return detail::functor2::call(lowerMultiple, Source, Multiple); + return detail::functor2::call(lowerMultiple, Source, Multiple); } }//namespace glm diff --git a/glm/gtx/simd_vec4.inl b/glm/gtx/simd_vec4.inl index 3e2cf9cc..ba5387c2 100644 --- a/glm/gtx/simd_vec4.inl +++ b/glm/gtx/simd_vec4.inl @@ -11,7 +11,7 @@ namespace glm{ namespace detail{ template -struct mask +struct shuffle_mask { enum{value = Value}; }; @@ -166,7 +166,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD fvec4SIMD::swizzle() const { __m128 Data = _mm_shuffle_ps( this->Data, this->Data, - mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); + shuffle_mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); return fvec4SIMD(Data); } @@ -175,7 +175,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::swizzle() { this->Data = _mm_shuffle_ps( this->Data, this->Data, - mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); + shuffle_mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); return *this; } diff --git a/test/gtc/gtc_bitfield.cpp b/test/gtc/gtc_bitfield.cpp index 2504d1c2..eed75a44 100644 --- a/test/gtc/gtc_bitfield.cpp +++ b/test/gtc/gtc_bitfield.cpp @@ -10,7 +10,9 @@ #include #include #include -//#include +#if GLM_ARCH != GLM_ARCH_PURE +# include +#endif #include #include #include diff --git a/test/gtc/gtc_integer.cpp b/test/gtc/gtc_integer.cpp index a6fab86a..e336b35c 100644 --- a/test/gtc/gtc_integer.cpp +++ b/test/gtc/gtc_integer.cpp @@ -10,8 +10,9 @@ #include #include #include -#include #include +#include +#include namespace isPowerOfTwo { @@ -254,8 +255,8 @@ namespace ceilPowerOfTwo std::clock_t Timestramp2 = std::clock(); - printf("ceilPowerOfTwo_loop: %d clocks\n", Timestramp1 - Timestramp0); - printf("glm::ceilPowerOfTwo: %d clocks\n", Timestramp2 - Timestramp1); + std::printf("ceilPowerOfTwo_loop: %d clocks\n", static_cast(Timestramp1 - Timestramp0)); + std::printf("glm::ceilPowerOfTwo: %d clocks\n", static_cast(Timestramp2 - Timestramp1)); return Error; } diff --git a/test/gtx/gtx_multiple.cpp b/test/gtx/gtx_multiple.cpp index df0c5842..f2500260 100644 --- a/test/gtx/gtx_multiple.cpp +++ b/test/gtx/gtx_multiple.cpp @@ -9,6 +9,42 @@ #include +int test_higher_uint() +{ + int Error(0); + + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(0), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(1), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(2), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(3), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(4), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(5), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(6), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(7), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(8), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1; + Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(9), glm::uvec4(4)), glm::uvec4(12))) ? 0 : 1; + + return Error; +} + +int test_Lower_uint() +{ + int Error(0); + + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(0), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(1), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(2), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(3), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(4), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(5), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(6), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(7), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(8), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1; + Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(9), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1; + + return Error; +} + int test_higher_int() { int Error(0); @@ -108,6 +144,8 @@ int main() Error += test_higher_int(); Error += test_Lower_int(); + Error += test_higher_uint(); + Error += test_Lower_uint(); Error += test_higher_double(); Error += test_Lower_double();