diff --git a/glm/core/type_vec.hpp b/glm/core/type_vec.hpp index c5e74e21..37cc980b 100644 --- a/glm/core/type_vec.hpp +++ b/glm/core/type_vec.hpp @@ -70,6 +70,9 @@ namespace detail typedef detail::tvec1 highp_uvec1_t; typedef detail::tvec1 mediump_uvec1_t; typedef detail::tvec1 lowp_uvec1_t; + typedef detail::tvec1 highp_bvec1_t; + typedef detail::tvec1 mediump_bvec1_t; + typedef detail::tvec1 lowp_bvec1_t; /// @addtogroup core_precision /// @{ diff --git a/glm/core/type_vec1.hpp b/glm/core/type_vec1.hpp index 28562e49..7a24d3ba 100644 --- a/glm/core/type_vec1.hpp +++ b/glm/core/type_vec1.hpp @@ -128,8 +128,14 @@ namespace detail GLM_FUNC_DECL tvec1 & operator/=(U const & s); template GLM_FUNC_DECL tvec1 & operator/=(tvec1 const & v); + + ////////////////////////////////////// + // Increment and decrement operators + GLM_FUNC_DECL tvec1 & operator++(); GLM_FUNC_DECL tvec1 & operator--(); + GLM_FUNC_DECL tvec1 operator++(int); + GLM_FUNC_DECL tvec1 operator--(int); ////////////////////////////////////// // Unary bit operators diff --git a/glm/core/type_vec1.inl b/glm/core/type_vec1.inl index 9a682799..18255d2c 100644 --- a/glm/core/type_vec1.inl +++ b/glm/core/type_vec1.inl @@ -266,6 +266,9 @@ namespace detail return *this; } + ////////////////////////////////////// + // Increment and decrement operators + template GLM_FUNC_QUALIFIER tvec1 & tvec1::operator++() { @@ -280,6 +283,22 @@ namespace detail return *this; } + template + GLM_FUNC_QUALIFIER tvec1 tvec1::operator++(int) + { + tvec1 Result(*this); + ++*this; + return Result; + } + + template + GLM_FUNC_QUALIFIER tvec1 tvec1::operator--(int) + { + tvec1 Result(*this); + --*this; + return Result; + } + ////////////////////////////////////// // Boolean operators diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index c6b82a0c..69c35f38 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -172,8 +172,14 @@ namespace detail GLM_FUNC_DECL tvec2 & operator/=(U const & s); template GLM_FUNC_DECL tvec2 & operator/=(tvec2 const & v); + + ////////////////////////////////////// + // Increment and decrement operators + GLM_FUNC_DECL tvec2 & operator++(); GLM_FUNC_DECL tvec2 & operator--(); + GLM_FUNC_DECL tvec2 operator++(int); + GLM_FUNC_DECL tvec2 operator--(int); ////////////////////////////////////// // Unary bit operators diff --git a/glm/core/type_vec2.inl b/glm/core/type_vec2.inl index 7ba4ce0c..290d9cd1 100644 --- a/glm/core/type_vec2.inl +++ b/glm/core/type_vec2.inl @@ -290,6 +290,9 @@ namespace detail return *this; } + ////////////////////////////////////// + // Increment and decrement operators + template GLM_FUNC_QUALIFIER tvec2 & tvec2::operator++() { @@ -306,6 +309,22 @@ namespace detail return *this; } + template + GLM_FUNC_QUALIFIER tvec2 tvec2::operator++(int) + { + tvec2 Result(*this); + ++*this; + return Result; + } + + template + GLM_FUNC_QUALIFIER tvec2 tvec2::operator--(int) + { + tvec2 Result(*this); + --*this; + return Result; + } + ////////////////////////////////////// // Boolean operators @@ -704,30 +723,6 @@ namespace detail -v.y); } - template - GLM_FUNC_QUALIFIER tvec2 operator++ - ( - tvec2 const & v, - int - ) - { - return tvec2( - v.x + T(1), - v.y + T(1)); - } - - template - GLM_FUNC_QUALIFIER tvec2 operator-- - ( - tvec2 const & v, - int - ) - { - return tvec2( - v.x - T(1), - v.y - T(1)); - } - ////////////////////////////////////// // Binary bit operators diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index 40ea7533..739b9c8c 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -196,8 +196,14 @@ namespace detail GLM_FUNC_DECL tvec3 & operator/=(U const & s); template GLM_FUNC_DECL tvec3 & operator/=(tvec3 const & v); + + ////////////////////////////////////// + // Increment and decrement operators + GLM_FUNC_DECL tvec3 & operator++(); GLM_FUNC_DECL tvec3 & operator--(); + GLM_FUNC_DECL tvec3 operator++(int); + GLM_FUNC_DECL tvec3 operator--(int); ////////////////////////////////////// // Unary bit operators diff --git a/glm/core/type_vec3.inl b/glm/core/type_vec3.inl index b9d623b4..e2985c23 100644 --- a/glm/core/type_vec3.inl +++ b/glm/core/type_vec3.inl @@ -349,6 +349,9 @@ namespace detail return *this; } + ////////////////////////////////////// + // Increment and decrement operators + template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator++() { @@ -367,6 +370,22 @@ namespace detail return *this; } + template + GLM_FUNC_QUALIFIER tvec3 tvec3::operator++(int) + { + tvec3 Result(*this); + ++*this; + return Result; + } + + template + GLM_FUNC_QUALIFIER tvec3 tvec3::operator--(int) + { + tvec3 Result(*this); + --*this; + return Result; + } + ////////////////////////////////////// // Boolean operators @@ -805,32 +824,6 @@ namespace detail -v.z); } - template - GLM_FUNC_QUALIFIER tvec3 operator++ - ( - tvec3 const & v, - int - ) - { - return tvec3( - v.x + T(1), - v.y + T(1), - v.z + T(1)); - } - - template - GLM_FUNC_QUALIFIER tvec3 operator-- - ( - tvec3 const & v, - int - ) - { - return tvec3( - v.x - T(1), - v.y - T(1), - v.z - T(1)); - } - ////////////////////////////////////// // Binary bit operators diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index e17ada57..11eec86e 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -251,8 +251,14 @@ namespace detail GLM_FUNC_DECL tvec4 & operator/=(U const & s); template GLM_FUNC_DECL tvec4 & operator/=(tvec4 const & v); + + ////////////////////////////////////// + // Increment and decrement operators + GLM_FUNC_DECL tvec4 & operator++(); GLM_FUNC_DECL tvec4 & operator--(); + GLM_FUNC_DECL tvec4 operator++(int); + GLM_FUNC_DECL tvec4 operator--(int); ////////////////////////////////////// // Unary bit operators diff --git a/glm/core/type_vec4.inl b/glm/core/type_vec4.inl index db68bb54..695f26a9 100644 --- a/glm/core/type_vec4.inl +++ b/glm/core/type_vec4.inl @@ -504,6 +504,9 @@ namespace detail return *this; } + ////////////////////////////////////// + // Increment and decrement operators + template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator++() { @@ -524,6 +527,22 @@ namespace detail return *this; } + template + GLM_FUNC_QUALIFIER tvec4 tvec4::operator++(int) + { + tvec4 Result(*this); + ++*this; + return Result; + } + + template + GLM_FUNC_QUALIFIER tvec4 tvec4::operator--(int) + { + tvec4 Result(*this); + --*this; + return Result; + } + ////////////////////////////////////// // Unary bit operators @@ -980,36 +999,6 @@ namespace detail -v.w); } - template - GLM_FUNC_QUALIFIER tvec4 operator++ - ( - tvec4 const & v, - int - ) - { - typename tvec4::value_type One(1); - return tvec4( - v.x + One, - v.y + One, - v.z + One, - v.w + One); - } - - template - GLM_FUNC_QUALIFIER tvec4 operator-- - ( - tvec4 const & v, - int - ) - { - typename tvec4::value_type One(1); - return tvec4( - v.x - One, - v.y - One, - v.z - One, - v.w - One); - } - ////////////////////////////////////// // Boolean operators diff --git a/glm/gtx/vec1.hpp b/glm/gtx/vec1.hpp index 7d37e6de..346c7ffa 100644 --- a/glm/gtx/vec1.hpp +++ b/glm/gtx/vec1.hpp @@ -50,59 +50,88 @@ namespace glm //! 1 component vector of high precision floating-point numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::highp_vec1_t highp_vec1; + typedef highp_vec1_t highp_vec1; + //! 1 component vector of medium precision floating-point numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::mediump_vec1_t mediump_vec1; + typedef mediump_vec1_t mediump_vec1; + //! 1 component vector of low precision floating-point numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::lowp_vec1_t lowp_vec1; + typedef lowp_vec1_t lowp_vec1; //! 1 component vector of high precision signed integer numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::highp_ivec1_t highp_ivec1; + typedef highp_ivec1_t highp_ivec1; + //! 1 component vector of medium precision signed integer numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::mediump_ivec1_t mediump_ivec1; + typedef mediump_ivec1_t mediump_ivec1; + //! 1 component vector of low precision signed integer numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::lowp_ivec1_t lowp_ivec1; + typedef lowp_ivec1_t lowp_ivec1; //! 1 component vector of high precision unsigned integer numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::highp_uvec1_t highp_uvec1; + typedef highp_uvec1_t highp_uvec1; + //! 1 component vector of medium precision unsigned integer numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::mediump_uvec1_t mediump_uvec1; + typedef mediump_uvec1_t mediump_uvec1; + //! 1 component vector of low precision unsigned integer numbers. //! There is no guarantee on the actual precision. //! From GLM_GTX_vec1 extension. - typedef detail::lowp_uvec1_t lowp_uvec1; + typedef lowp_uvec1_t lowp_uvec1; + + //! 1 component vector of high precision boolean. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef highp_bvec1_t highp_bvec1; + + //! 1 component vector of medium precision boolean. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef mediump_bvec1_t mediump_bvec1; + + //! 1 component vector of low precision boolean. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef lowp_bvec1_t lowp_bvec1; ////////////////////////// // vec1 definition - //! 1 component vector of boolean. - //! From GLM_GTX_vec1 extension. - typedef detail::tvec1 bvec1; +#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. + /// From GLM_GTX_vec1 extension. + typedef highp_bvec1 bvec1; +#endif//GLM_PRECISION #if(defined(GLM_PRECISION_HIGHP_FLOAT)) - typedef highp_vec1 vec1; + typedef highp_vec1 vec1; #elif(defined(GLM_PRECISION_MEDIUMP_FLOAT)) typedef mediump_vec1 vec1; #elif(defined(GLM_PRECISION_LOWP_FLOAT)) - typedef lowp_vec1 vec1; + typedef lowp_vec1 vec1; #else - //! 1 component vector of floating-point numbers. - //! From GLM_GTX_vec1 extension. - typedef mediump_vec1 vec1; + /// 1 component vector of floating-point numbers. + /// From GLM_GTX_vec1 extension. + typedef highp_vec1 vec1; #endif//GLM_PRECISION #if(defined(GLM_PRECISION_HIGHP_INT)) @@ -112,9 +141,9 @@ namespace glm #elif(defined(GLM_PRECISION_LOWP_INT)) typedef lowp_ivec1 ivec1; #else - //! 1 component vector of signed integer numbers. - //! From GLM_GTX_vec1 extension. - typedef mediump_ivec1 ivec1; + /// 1 component vector of signed integer numbers. + /// From GLM_GTX_vec1 extension. + typedef highp_ivec1 ivec1; #endif//GLM_PRECISION #if(defined(GLM_PRECISION_HIGHP_UINT)) @@ -124,9 +153,9 @@ namespace glm #elif(defined(GLM_PRECISION_LOWP_UINT)) typedef lowp_uvec1 uvec1; #else - //! 1 component vector of unsigned integer numbers. - //! From GLM_GTX_vec1 extension. - typedef mediump_uvec1 uvec1; + /// 1 component vector of unsigned integer numbers. + /// From GLM_GTX_vec1 extension. + typedef highp_uvec1 uvec1; #endif//GLM_PRECISION }// namespace glm diff --git a/readme.txt b/readme.txt index 6a5f12e9..d0f7a698 100644 --- a/readme.txt +++ b/readme.txt @@ -49,6 +49,7 @@ GLM 0.9.5.0: 2013-XX-XX - Added quaternion comparison functions - Fixed GTX_multiple for negative value - Removed GTX_ocl_type extension +- Fixed post increment and decrement operators ================================================================================ GLM 0.9.4.4: 2013-0X-XX diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index 7c9189ae..7c0834ab 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -9,8 +9,9 @@ #define GLM_SWIZZLE #include +#include -static int test_operators() +int test_operators() { glm::vec4 A(1.0f); glm::vec4 B(1.0f); @@ -20,11 +21,39 @@ static int test_operators() return (S && !R) ? 0 : 1; } +int test_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; +} + int main() { int Error = 0; Error += test_operators(); + Error += test_operator_increment(); return Error; } diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 37cc8aba..34abeba8 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -218,6 +218,33 @@ int test_vec2_size() return Error; } +int test_operator_increment() +{ + int Error(0); + + glm::ivec2 v0(1); + glm::ivec2 v1(v0); + glm::ivec2 v2(v0); + glm::ivec2 v3 = ++v1; + glm::ivec2 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; +} + int main() { int Error = 0; @@ -225,6 +252,7 @@ int main() Error += test_vec2_size(); Error += test_vec2_ctor(); Error += test_vec2_operators(); + Error += test_operator_increment(); return Error; } diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index 7d17a410..b6d6cba9 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -421,6 +421,33 @@ int test_vec3_swizzle_partial() return Error; } +int test_operator_increment() +{ + int Error(0); + + glm::ivec3 v0(1); + glm::ivec3 v1(v0); + glm::ivec3 v2(v0); + glm::ivec3 v3 = ++v1; + glm::ivec3 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; +} + int main() { int Error = 0; @@ -434,6 +461,7 @@ int main() Error += test_vec3_swizzle_partial(); Error += test_vec3_swizzle_operators(); Error += test_vec3_swizzle_functions(); + Error += test_operator_increment(); return Error; } diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index c10a13f1..7d6a87a2 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -255,17 +255,47 @@ int test_vec4_swizzle_partial() return Error; } +int test_operator_increment() +{ + int Error(0); + + glm::ivec4 v0(1); + glm::ivec4 v1(v0); + glm::ivec4 v2(v0); + glm::ivec4 v3 = ++v1; + glm::ivec4 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; +} + int main() { //__m128 DataA = swizzle(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); //__m128 DataB = swizzle(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); - int Error = 0; + int Error(0); + Error += test_vec4_ctor(); Error += test_vec4_size(); Error += test_vec4_operators(); Error += test_hvec4(); Error += test_vec4_swizzle_partial(); + Error += test_operator_increment(); + return Error; }