mirror of
https://github.com/g-truc/glm.git
synced 2024-11-23 01:14:34 +00:00
Fixed GLM_FORCE_SIZE_FUNC and added test #245
This commit is contained in:
parent
b2ce1a726b
commit
85037a164f
@ -138,20 +138,15 @@ namespace detail
|
|||||||
|
|
||||||
GLM_FUNC_QUALIFIER value_type& operator[] (size_t i)
|
GLM_FUNC_QUALIFIER value_type& operator[] (size_t i)
|
||||||
{
|
{
|
||||||
#ifndef __CUDA_ARCH__
|
const int offset_dst[4] = { E0, E1, E2, E3 };
|
||||||
static
|
|
||||||
#endif
|
|
||||||
const int offset_dst[4] = { E0, E1, E2, E3 };
|
|
||||||
return this->elem(offset_dst[i]);
|
return this->elem(offset_dst[i]);
|
||||||
}
|
}
|
||||||
GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const
|
GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const
|
||||||
{
|
{
|
||||||
#ifndef __CUDA_ARCH__
|
const int offset_dst[4] = { E0, E1, E2, E3 };
|
||||||
static
|
|
||||||
#endif
|
|
||||||
const int offset_dst[4] = { E0, E1, E2, E3 };
|
|
||||||
return this->elem(offset_dst[i]);
|
return this->elem(offset_dst[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER void _apply_op(const VecType& that, T op)
|
GLM_FUNC_QUALIFIER void _apply_op(const VecType& that, T op)
|
||||||
@ -179,10 +174,7 @@ namespace detail
|
|||||||
|
|
||||||
GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const
|
GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const
|
||||||
{
|
{
|
||||||
#ifndef __CUDA_ARCH__
|
const int offset_dst[4] = { E0, E1, E2, E3 };
|
||||||
static
|
|
||||||
#endif
|
|
||||||
const int offset_dst[4] = { E0, E1, E2, E3 };
|
|
||||||
return this->elem(offset_dst[i]);
|
return this->elem(offset_dst[i]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -808,21 +808,21 @@ namespace glm
|
|||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
|
typedef size_t component_count_t;
|
||||||
|
# else
|
||||||
|
typedef length_t component_count_t;
|
||||||
|
# endif
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t component_count(genType const & m)
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR component_count_t component_count(genType const & m)
|
||||||
{
|
{
|
||||||
# if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
return m.size();
|
return m.size();
|
||||||
# else
|
# else
|
||||||
return m.length();
|
return m.length();
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
# if GLM_FORCE_SIZE_FUNC
|
|
||||||
typedef size_t component_count_t;
|
|
||||||
# else
|
|
||||||
typedef length_t component_count_t;
|
|
||||||
# endif
|
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@ namespace glm
|
|||||||
typedef tmat2x2<T, P> type;
|
typedef tmat2x2<T, P> type;
|
||||||
typedef tmat2x2<T, P> transpose_type;
|
typedef tmat2x2<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
template <typename U, precision Q>
|
template <typename U, precision Q>
|
||||||
friend tvec2<U, Q> operator/(tmat2x2<U, Q> const & m, tvec2<U, Q> const & v);
|
friend tvec2<U, Q> operator/(tmat2x2<U, Q> const & m, tvec2<U, Q> const & v);
|
||||||
|
@ -46,7 +46,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x2<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x2<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,11 @@ namespace glm
|
|||||||
typedef tmat2x3<T, P> type;
|
typedef tmat2x3<T, P> type;
|
||||||
typedef tmat3x2<T, P> transpose_type;
|
typedef tmat3x2<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data
|
// Data
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x3<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x3<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,11 @@ namespace glm
|
|||||||
typedef tmat2x4<T, P> type;
|
typedef tmat2x4<T, P> type;
|
||||||
typedef tmat4x2<T, P> transpose_type;
|
typedef tmat4x2<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data
|
// Data
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x4<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x4<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,11 @@ namespace glm
|
|||||||
typedef tmat3x2<T, P> type;
|
typedef tmat3x2<T, P> type;
|
||||||
typedef tmat2x3<T, P> transpose_type;
|
typedef tmat2x3<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data
|
// Data
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x2<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x2<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -47,11 +47,11 @@ namespace glm
|
|||||||
typedef tmat3x3<T, P> type;
|
typedef tmat3x3<T, P> type;
|
||||||
typedef tmat3x3<T, P> transpose_type;
|
typedef tmat3x3<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
template <typename U, precision Q>
|
template <typename U, precision Q>
|
||||||
friend tvec3<U, Q> operator/(tmat3x3<U, Q> const & m, tvec3<U, Q> const & v);
|
friend tvec3<U, Q> operator/(tmat3x3<U, Q> const & m, tvec3<U, Q> const & v);
|
||||||
|
@ -52,7 +52,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x3<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x3<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,11 @@ namespace glm
|
|||||||
typedef tmat3x4<T, P> type;
|
typedef tmat3x4<T, P> type;
|
||||||
typedef tmat4x3<T, P> transpose_type;
|
typedef tmat4x3<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data
|
// Data
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x4<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x4<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,11 @@ namespace glm
|
|||||||
typedef tmat4x2<T, P> type;
|
typedef tmat4x2<T, P> type;
|
||||||
typedef tmat2x4<T, P> transpose_type;
|
typedef tmat2x4<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data
|
// Data
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x2<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x2<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,11 @@ namespace glm
|
|||||||
typedef tmat4x3<T, P> type;
|
typedef tmat4x3<T, P> type;
|
||||||
typedef tmat3x4<T, P> transpose_type;
|
typedef tmat3x4<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data
|
// Data
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x3<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x3<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -47,11 +47,11 @@ namespace glm
|
|||||||
typedef tmat4x4<T, P> type;
|
typedef tmat4x4<T, P> type;
|
||||||
typedef tmat4x4<T, P> transpose_type;
|
typedef tmat4x4<T, P> transpose_type;
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
#else
|
# else
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
#endif//GLM_FORCE_SIZE_FUNC
|
# endif//GLM_FORCE_SIZE_FUNC
|
||||||
|
|
||||||
template <typename U, precision Q>
|
template <typename U, precision Q>
|
||||||
friend tvec4<U, Q> operator/(tmat4x4<U, Q> const & m, tvec4<U, Q> const & v);
|
friend tvec4<U, Q> operator/(tmat4x4<U, Q> const & m, tvec4<U, Q> const & v);
|
||||||
|
@ -88,7 +88,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
|
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x4<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x4<T, P>::size() const
|
||||||
{
|
{
|
||||||
|
@ -41,6 +41,9 @@ namespace glm
|
|||||||
typedef tvec1<float, highp> highp_vec1_t;
|
typedef tvec1<float, highp> highp_vec1_t;
|
||||||
typedef tvec1<float, mediump> mediump_vec1_t;
|
typedef tvec1<float, mediump> mediump_vec1_t;
|
||||||
typedef tvec1<float, lowp> lowp_vec1_t;
|
typedef tvec1<float, lowp> lowp_vec1_t;
|
||||||
|
typedef tvec1<double, highp> highp_dvec1_t;
|
||||||
|
typedef tvec1<double, mediump> mediump_dvec1_t;
|
||||||
|
typedef tvec1<double, lowp> lowp_dvec1_t;
|
||||||
typedef tvec1<int, highp> highp_ivec1_t;
|
typedef tvec1<int, highp> highp_ivec1_t;
|
||||||
typedef tvec1<int, mediump> mediump_ivec1_t;
|
typedef tvec1<int, mediump> mediump_ivec1_t;
|
||||||
typedef tvec1<int, lowp> lowp_ivec1_t;
|
typedef tvec1<int, lowp> lowp_ivec1_t;
|
||||||
|
@ -56,7 +56,7 @@ namespace glm
|
|||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Helper
|
// Helper
|
||||||
|
|
||||||
# if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
/// Return the count of components of the vector
|
/// Return the count of components of the vector
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
# else
|
# else
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec1<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec1<T, P>::size() const
|
||||||
{
|
{
|
||||||
@ -48,14 +48,14 @@ namespace glm
|
|||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER T & tvec1<T, P>::operator[](length_t i)
|
GLM_FUNC_QUALIFIER T & tvec1<T, P>::operator[](length_t i)
|
||||||
{
|
{
|
||||||
assert(i >= 0 && i < this->length());
|
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||||
return (&x)[i];
|
return (&x)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER T const & tvec1<T, P>::operator[](length_t i) const
|
GLM_FUNC_QUALIFIER T const & tvec1<T, P>::operator[](length_t i) const
|
||||||
{
|
{
|
||||||
assert(i >= 0 && i < this->length());
|
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||||
return (&x)[i];
|
return (&x)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace glm
|
|||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Helper
|
// Helper
|
||||||
|
|
||||||
# if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
/// Return the count of components of the vector
|
/// Return the count of components of the vector
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
# else
|
# else
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec2<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec2<T, P>::size() const
|
||||||
{
|
{
|
||||||
@ -48,14 +48,14 @@ namespace glm
|
|||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](length_t i)
|
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](length_t i)
|
||||||
{
|
{
|
||||||
assert(i >= 0 && i < this->length());
|
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||||
return (&x)[i];
|
return (&x)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](length_t i) const
|
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](length_t i) const
|
||||||
{
|
{
|
||||||
assert(i >= 0 && i < this->length());
|
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||||
return (&x)[i];
|
return (&x)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace glm
|
|||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Helper
|
// Helper
|
||||||
|
|
||||||
# if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
/// Return the count of components of the vector
|
/// Return the count of components of the vector
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
# else
|
# else
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec3<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec3<T, P>::size() const
|
||||||
{
|
{
|
||||||
@ -48,14 +48,14 @@ namespace glm
|
|||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER T & tvec3<T, P>::operator[](length_t i)
|
GLM_FUNC_QUALIFIER T & tvec3<T, P>::operator[](length_t i)
|
||||||
{
|
{
|
||||||
assert(i >= 0 && i < this->length());
|
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||||
return (&x)[i];
|
return (&x)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER T const & tvec3<T, P>::operator[](length_t i) const
|
GLM_FUNC_QUALIFIER T const & tvec3<T, P>::operator[](length_t i) const
|
||||||
{
|
{
|
||||||
assert(i >= 0 && i < this->length());
|
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||||
return (&x)[i];
|
return (&x)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ namespace glm
|
|||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Helper
|
// Helper
|
||||||
|
|
||||||
# if GLM_FORCE_SIZE_FUNC
|
# ifdef GLM_FORCE_SIZE_FUNC
|
||||||
/// Return the count of components of the vector
|
/// Return the count of components of the vector
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
|
||||||
# else
|
# else
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
#if GLM_FORCE_SIZE_FUNC
|
#ifdef GLM_FORCE_SIZE_FUNC
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec4<T, P>::size() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec4<T, P>::size() const
|
||||||
{
|
{
|
||||||
@ -48,14 +48,14 @@ namespace glm
|
|||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER T & tvec4<T, P>::operator[](length_t i)
|
GLM_FUNC_QUALIFIER T & tvec4<T, P>::operator[](length_t i)
|
||||||
{
|
{
|
||||||
assert(i >= 0 && i < this->length());
|
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||||
return (&x)[i];
|
return (&x)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER T const & tvec4<T, P>::operator[](length_t i) const
|
GLM_FUNC_QUALIFIER T const & tvec4<T, P>::operator[](length_t i) const
|
||||||
{
|
{
|
||||||
assert(i >= 0 && i < this->length());
|
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
|
||||||
return (&x)[i];
|
return (&x)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,21 @@ namespace glm
|
|||||||
/// @see gtx_vec1 extension.
|
/// @see gtx_vec1 extension.
|
||||||
typedef lowp_vec1_t lowp_vec1;
|
typedef lowp_vec1_t lowp_vec1;
|
||||||
|
|
||||||
|
//! 1 component vector of high precision floating-point numbers.
|
||||||
|
//! There is no guarantee on the actual precision.
|
||||||
|
/// @see gtx_vec1 extension.
|
||||||
|
typedef highp_dvec1_t highp_dvec1;
|
||||||
|
|
||||||
|
//! 1 component vector of medium precision floating-point numbers.
|
||||||
|
//! There is no guarantee on the actual precision.
|
||||||
|
/// @see gtx_vec1 extension.
|
||||||
|
typedef mediump_dvec1_t mediump_dvec1;
|
||||||
|
|
||||||
|
//! 1 component vector of low precision floating-point numbers.
|
||||||
|
//! There is no guarantee on the actual precision.
|
||||||
|
/// @see gtx_vec1 extension.
|
||||||
|
typedef lowp_dvec1_t lowp_dvec1;
|
||||||
|
|
||||||
//! 1 component vector of high precision signed integer numbers.
|
//! 1 component vector of high precision signed integer numbers.
|
||||||
//! There is no guarantee on the actual precision.
|
//! There is no guarantee on the actual precision.
|
||||||
/// @see gtx_vec1 extension.
|
/// @see gtx_vec1 extension.
|
||||||
@ -133,6 +148,18 @@ namespace glm
|
|||||||
typedef highp_vec1 vec1;
|
typedef highp_vec1 vec1;
|
||||||
#endif//GLM_PRECISION
|
#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 gtx_vec1 extension.
|
||||||
|
typedef highp_dvec1 dvec1;
|
||||||
|
#endif//GLM_PRECISION
|
||||||
|
|
||||||
#if(defined(GLM_PRECISION_HIGHP_INT))
|
#if(defined(GLM_PRECISION_HIGHP_INT))
|
||||||
typedef highp_ivec1 ivec1;
|
typedef highp_ivec1 ivec1;
|
||||||
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
|
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
|
||||||
|
@ -2,6 +2,7 @@ glmCreateTestGTC(core_type_cast)
|
|||||||
glmCreateTestGTC(core_type_float)
|
glmCreateTestGTC(core_type_float)
|
||||||
glmCreateTestGTC(core_type_int)
|
glmCreateTestGTC(core_type_int)
|
||||||
glmCreateTestGTC(core_type_length)
|
glmCreateTestGTC(core_type_length)
|
||||||
|
glmCreateTestGTC(core_type_length_size)
|
||||||
glmCreateTestGTC(core_type_mat2x2)
|
glmCreateTestGTC(core_type_mat2x2)
|
||||||
glmCreateTestGTC(core_type_mat2x3)
|
glmCreateTestGTC(core_type_mat2x3)
|
||||||
glmCreateTestGTC(core_type_mat2x4)
|
glmCreateTestGTC(core_type_mat2x4)
|
||||||
|
94
test/core/core_type_length_size.cpp
Normal file
94
test/core/core_type_length_size.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Created : 2011-05-25
|
||||||
|
// Updated : 2011-05-25
|
||||||
|
// Licence : This source is under MIT License
|
||||||
|
// File : test/core/type_length.cpp
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define GLM_FORCE_SIZE_FUNC
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/vec1.hpp>
|
||||||
|
|
||||||
|
int test_length_mat_non_squared()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
Error += glm::mat2x3().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::mat2x4().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::mat3x2().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::mat3x4().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::mat4x2().size() == 4 ? 0 : 1;
|
||||||
|
Error += glm::mat4x3().size() == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
Error += glm::dmat2x3().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::dmat2x4().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::dmat3x2().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::dmat3x4().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::dmat4x2().size() == 4 ? 0 : 1;
|
||||||
|
Error += glm::dmat4x3().size() == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_length_mat()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
Error += glm::mat2().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::mat3().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::mat4().size() == 4 ? 0 : 1;
|
||||||
|
Error += glm::mat2x2().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::mat3x3().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::mat4x4().size() == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
Error += glm::dmat2().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::dmat3().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::dmat4().size() == 4 ? 0 : 1;
|
||||||
|
Error += glm::dmat2x2().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::dmat3x3().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::dmat4x4().size() == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_length_vec()
|
||||||
|
{
|
||||||
|
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
Error += glm::vec1().size() == 1 ? 0 : 1;
|
||||||
|
Error += glm::vec2().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::vec3().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::vec4().size() == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
Error += glm::ivec1().size() == 1 ? 0 : 1;
|
||||||
|
Error += glm::ivec2().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::ivec3().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::ivec4().size() == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
Error += glm::uvec1().size() == 1 ? 0 : 1;
|
||||||
|
Error += glm::uvec2().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::uvec3().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::uvec4().size() == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
Error += glm::dvec1().size() == 1 ? 0 : 1;
|
||||||
|
Error += glm::dvec2().size() == 2 ? 0 : 1;
|
||||||
|
Error += glm::dvec3().size() == 3 ? 0 : 1;
|
||||||
|
Error += glm::dvec4().size() == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
Error += test_length_vec();
|
||||||
|
Error += test_length_mat();
|
||||||
|
Error += test_length_mat_non_squared();
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user