Fixed post in/decrement operators

This commit is contained in:
Christophe Riccio 2013-05-08 21:52:21 +02:00
parent 28c6bba18c
commit 691f04e14f
15 changed files with 273 additions and 105 deletions

View File

@ -70,6 +70,9 @@ namespace detail
typedef detail::tvec1<uint, highp> highp_uvec1_t;
typedef detail::tvec1<uint, mediump> mediump_uvec1_t;
typedef detail::tvec1<uint, lowp> lowp_uvec1_t;
typedef detail::tvec1<bool, highp> highp_bvec1_t;
typedef detail::tvec1<bool, mediump> mediump_bvec1_t;
typedef detail::tvec1<bool, lowp> lowp_bvec1_t;
/// @addtogroup core_precision
/// @{

View File

@ -128,8 +128,14 @@ namespace detail
GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
template <typename U>
GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tvec1<T, P> & operator++();
GLM_FUNC_DECL tvec1<T, P> & operator--();
GLM_FUNC_DECL tvec1<T, P> operator++(int);
GLM_FUNC_DECL tvec1<T, P> operator--(int);
//////////////////////////////////////
// Unary bit operators

View File

@ -266,6 +266,9 @@ namespace detail
return *this;
}
//////////////////////////////////////
// Increment and decrement operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> & tvec1<T, P>::operator++()
{
@ -280,6 +283,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> tvec1<T, P>::operator++(int)
{
tvec1<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> tvec1<T, P>::operator--(int)
{
tvec1<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////
// Boolean operators

View File

@ -172,8 +172,14 @@ namespace detail
GLM_FUNC_DECL tvec2<T, P> & operator/=(U const & s);
template <typename U>
GLM_FUNC_DECL tvec2<T, P> & operator/=(tvec2<U, P> const & v);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tvec2<T, P> & operator++();
GLM_FUNC_DECL tvec2<T, P> & operator--();
GLM_FUNC_DECL tvec2<T, P> operator++(int);
GLM_FUNC_DECL tvec2<T, P> operator--(int);
//////////////////////////////////////
// Unary bit operators

View File

@ -290,6 +290,9 @@ namespace detail
return *this;
}
//////////////////////////////////////
// Increment and decrement operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> & tvec2<T, P>::operator++()
{
@ -306,6 +309,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> tvec2<T, P>::operator++(int)
{
tvec2<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> tvec2<T, P>::operator--(int)
{
tvec2<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////
// Boolean operators
@ -704,30 +723,6 @@ namespace detail
-v.y);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator++
(
tvec2<T, P> const & v,
int
)
{
return tvec2<T, P>(
v.x + T(1),
v.y + T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> operator--
(
tvec2<T, P> const & v,
int
)
{
return tvec2<T, P>(
v.x - T(1),
v.y - T(1));
}
//////////////////////////////////////
// Binary bit operators

View File

@ -196,8 +196,14 @@ namespace detail
GLM_FUNC_DECL tvec3<T, P> & operator/=(U const & s);
template <typename U>
GLM_FUNC_DECL tvec3<T, P> & operator/=(tvec3<U, P> const & v);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tvec3<T, P> & operator++();
GLM_FUNC_DECL tvec3<T, P> & operator--();
GLM_FUNC_DECL tvec3<T, P> operator++(int);
GLM_FUNC_DECL tvec3<T, P> operator--(int);
//////////////////////////////////////
// Unary bit operators

View File

@ -349,6 +349,9 @@ namespace detail
return *this;
}
//////////////////////////////////////
// Increment and decrement operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator++()
{
@ -367,6 +370,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> tvec3<T, P>::operator++(int)
{
tvec3<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> tvec3<T, P>::operator--(int)
{
tvec3<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////
// Boolean operators
@ -805,32 +824,6 @@ namespace detail
-v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator++
(
tvec3<T, P> const & v,
int
)
{
return tvec3<T, P>(
v.x + T(1),
v.y + T(1),
v.z + T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> operator--
(
tvec3<T, P> const & v,
int
)
{
return tvec3<T, P>(
v.x - T(1),
v.y - T(1),
v.z - T(1));
}
//////////////////////////////////////
// Binary bit operators

View File

@ -251,8 +251,14 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> & operator/=(U const & s);
template <typename U>
GLM_FUNC_DECL tvec4<T, P> & operator/=(tvec4<U, P> const & v);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tvec4<T, P> & operator++();
GLM_FUNC_DECL tvec4<T, P> & operator--();
GLM_FUNC_DECL tvec4<T, P> operator++(int);
GLM_FUNC_DECL tvec4<T, P> operator--(int);
//////////////////////////////////////
// Unary bit operators

View File

@ -504,6 +504,9 @@ namespace detail
return *this;
}
//////////////////////////////////////
// Increment and decrement operators
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator++()
{
@ -524,6 +527,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> tvec4<T, P>::operator++(int)
{
tvec4<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> tvec4<T, P>::operator--(int)
{
tvec4<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////
// Unary bit operators
@ -980,36 +999,6 @@ namespace detail
-v.w);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator++
(
tvec4<T, P> const & v,
int
)
{
typename tvec4<T, P>::value_type One(1);
return tvec4<T, P>(
v.x + One,
v.y + One,
v.z + One,
v.w + One);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> operator--
(
tvec4<T, P> const & v,
int
)
{
typename tvec4<T, P>::value_type One(1);
return tvec4<T, P>(
v.x - One,
v.y - One,
v.z - One,
v.w - One);
}
//////////////////////////////////////
// Boolean operators

View File

@ -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<bool> 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

View File

@ -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

View File

@ -9,8 +9,9 @@
#define GLM_SWIZZLE
#include <glm/glm.hpp>
#include <glm/gtx/vec1.hpp>
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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<X, Y, Z, W>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
//__m128 DataB = swizzle<W, Z, Y, X>(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;
}