diff --git a/glm/detail/_swizzle.hpp b/glm/detail/_swizzle.hpp index ebe37319..0e01d7a2 100644 --- a/glm/detail/_swizzle.hpp +++ b/glm/detail/_swizzle.hpp @@ -138,20 +138,15 @@ namespace detail GLM_FUNC_QUALIFIER value_type& operator[] (size_t i) { -#ifndef __CUDA_ARCH__ - static -#endif - const int offset_dst[4] = { E0, E1, E2, E3 }; + const int offset_dst[4] = { E0, E1, E2, E3 }; return this->elem(offset_dst[i]); } GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const { -#ifndef __CUDA_ARCH__ - static -#endif - const int offset_dst[4] = { E0, E1, E2, E3 }; + const int offset_dst[4] = { E0, E1, E2, E3 }; return this->elem(offset_dst[i]); } + protected: template 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 { -#ifndef __CUDA_ARCH__ - static -#endif - const int offset_dst[4] = { E0, E1, E2, E3 }; + const int offset_dst[4] = { E0, E1, E2, E3 }; return this->elem(offset_dst[i]); } }; diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 935a1f58..4bf77b1d 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -808,21 +808,21 @@ namespace glm namespace detail { +# ifdef GLM_FORCE_SIZE_FUNC + typedef size_t component_count_t; +# else + typedef length_t component_count_t; +# endif + template - 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(); # else return m.length(); # endif } - -# if GLM_FORCE_SIZE_FUNC - typedef size_t component_count_t; -# else - typedef length_t component_count_t; -# endif }//namespace detail }//namespace glm diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index aedb8f7f..c3f2a81f 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -47,11 +47,11 @@ namespace glm typedef tmat2x2 type; typedef tmat2x2 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC template friend tvec2 operator/(tmat2x2 const & m, tvec2 const & v); diff --git a/glm/detail/type_mat2x2.inl b/glm/detail/type_mat2x2.inl index 591210a7..bf80a7f8 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -46,7 +46,7 @@ namespace detail } }//namespace detail -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x2::size() const { diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index 9c215f1b..73b611f7 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -48,11 +48,11 @@ namespace glm typedef tmat2x3 type; typedef tmat3x2 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC private: // Data diff --git a/glm/detail/type_mat2x3.inl b/glm/detail/type_mat2x3.inl index b5001b92..545c41ee 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x3::size() const { diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index ece80ae5..a5bf867f 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -48,11 +48,11 @@ namespace glm typedef tmat2x4 type; typedef tmat4x2 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC private: // Data diff --git a/glm/detail/type_mat2x4.inl b/glm/detail/type_mat2x4.inl index ab955988..10905fa7 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x4::size() const { diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index 6317d07b..abf1fb73 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -48,11 +48,11 @@ namespace glm typedef tmat3x2 type; typedef tmat2x3 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC private: // Data diff --git a/glm/detail/type_mat3x2.inl b/glm/detail/type_mat3x2.inl index c689b5f8..3bfae905 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x2::size() const { diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index cd3342d5..5fd1eb5f 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -47,11 +47,11 @@ namespace glm typedef tmat3x3 type; typedef tmat3x3 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC template friend tvec3 operator/(tmat3x3 const & m, tvec3 const & v); diff --git a/glm/detail/type_mat3x3.inl b/glm/detail/type_mat3x3.inl index 0b4fd900..b9ca0b5d 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -52,7 +52,7 @@ namespace detail } }//namespace detail -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x3::size() const { diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index 301766bd..dd5e746d 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -48,11 +48,11 @@ namespace glm typedef tmat3x4 type; typedef tmat4x3 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC private: // Data diff --git a/glm/detail/type_mat3x4.inl b/glm/detail/type_mat3x4.inl index 4003eb8e..1d9096db 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x4::size() const { diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index bb071030..ca3fa591 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -48,11 +48,11 @@ namespace glm typedef tmat4x2 type; typedef tmat2x4 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC private: // Data diff --git a/glm/detail/type_mat4x2.inl b/glm/detail/type_mat4x2.inl index d75cf0a1..9db63246 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x2::size() const { diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index acc7c4d3..f4f278aa 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -48,11 +48,11 @@ namespace glm typedef tmat4x3 type; typedef tmat3x4 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC private: // Data diff --git a/glm/detail/type_mat4x3.inl b/glm/detail/type_mat4x3.inl index 40d84684..292c4aa6 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x3::size() const { diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index a52b413e..a1c6d3fb 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -47,11 +47,11 @@ namespace glm typedef tmat4x4 type; typedef tmat4x4 transpose_type; -#if GLM_FORCE_SIZE_FUNC - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC template friend tvec4 operator/(tmat4x4 const & m, tvec4 const & v); diff --git a/glm/detail/type_mat4x4.inl b/glm/detail/type_mat4x4.inl index 3bc2135a..52015759 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -88,7 +88,7 @@ namespace detail } }//namespace detail -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x4::size() const { diff --git a/glm/detail/type_vec.hpp b/glm/detail/type_vec.hpp index 2aed1621..95e1e9f5 100644 --- a/glm/detail/type_vec.hpp +++ b/glm/detail/type_vec.hpp @@ -41,6 +41,9 @@ namespace glm typedef tvec1 highp_vec1_t; typedef tvec1 mediump_vec1_t; typedef tvec1 lowp_vec1_t; + typedef tvec1 highp_dvec1_t; + typedef tvec1 mediump_dvec1_t; + typedef tvec1 lowp_dvec1_t; typedef tvec1 highp_ivec1_t; typedef tvec1 mediump_ivec1_t; typedef tvec1 lowp_ivec1_t; diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 8389b6b7..50f15515 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -56,7 +56,7 @@ namespace glm ////////////////////////////////////// // Helper -# if GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC /// Return the count of components of the vector GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; # else diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index b5e67971..7d031c87 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec1::size() const { @@ -48,14 +48,14 @@ namespace glm template GLM_FUNC_QUALIFIER T & tvec1::operator[](length_t i) { - assert(i >= 0 && i < this->length()); + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); return (&x)[i]; } template GLM_FUNC_QUALIFIER T const & tvec1::operator[](length_t i) const { - assert(i >= 0 && i < this->length()); + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); return (&x)[i]; } diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 5c63a8a3..c817e74f 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -57,7 +57,7 @@ namespace glm ////////////////////////////////////// // Helper -# if GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC /// Return the count of components of the vector GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; # else diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index a2994de2..1ba2e269 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec2::size() const { @@ -48,14 +48,14 @@ namespace glm template GLM_FUNC_QUALIFIER T & tvec2::operator[](length_t i) { - assert(i >= 0 && i < this->length()); + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); return (&x)[i]; } template GLM_FUNC_QUALIFIER T const & tvec2::operator[](length_t i) const { - assert(i >= 0 && i < this->length()); + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); return (&x)[i]; } diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index a51b6d4e..bf703267 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -57,7 +57,7 @@ namespace glm ////////////////////////////////////// // Helper -# if GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC /// Return the count of components of the vector GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; # else diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index dd137fe9..4f357814 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec3::size() const { @@ -48,14 +48,14 @@ namespace glm template GLM_FUNC_QUALIFIER T & tvec3::operator[](length_t i) { - assert(i >= 0 && i < this->length()); + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); return (&x)[i]; } template GLM_FUNC_QUALIFIER T const & tvec3::operator[](length_t i) const { - assert(i >= 0 && i < this->length()); + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); return (&x)[i]; } diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 1bb565f3..9d22ec5a 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -80,7 +80,7 @@ namespace glm ////////////////////////////////////// // Helper -# if GLM_FORCE_SIZE_FUNC +# ifdef GLM_FORCE_SIZE_FUNC /// Return the count of components of the vector GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; # else diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 8a94b05b..da5f2855 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -28,7 +28,7 @@ namespace glm { -#if GLM_FORCE_SIZE_FUNC +#ifdef GLM_FORCE_SIZE_FUNC template GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec4::size() const { @@ -48,14 +48,14 @@ namespace glm template GLM_FUNC_QUALIFIER T & tvec4::operator[](length_t i) { - assert(i >= 0 && i < this->length()); + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); return (&x)[i]; } template GLM_FUNC_QUALIFIER T const & tvec4::operator[](length_t i) const { - assert(i >= 0 && i < this->length()); + assert(i >= 0 && static_cast(i) < detail::component_count(*this)); return (&x)[i]; } diff --git a/glm/gtc/vec1.hpp b/glm/gtc/vec1.hpp index 57e59e5e..93c6ecec 100644 --- a/glm/gtc/vec1.hpp +++ b/glm/gtc/vec1.hpp @@ -61,6 +61,21 @@ namespace glm /// @see gtx_vec1 extension. 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. //! There is no guarantee on the actual precision. /// @see gtx_vec1 extension. @@ -133,6 +148,18 @@ namespace glm typedef highp_vec1 vec1; #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)) typedef highp_ivec1 ivec1; #elif(defined(GLM_PRECISION_MEDIUMP_INT)) diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 0f5b9b49..4669faff 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -2,6 +2,7 @@ glmCreateTestGTC(core_type_cast) glmCreateTestGTC(core_type_float) glmCreateTestGTC(core_type_int) glmCreateTestGTC(core_type_length) +glmCreateTestGTC(core_type_length_size) glmCreateTestGTC(core_type_mat2x2) glmCreateTestGTC(core_type_mat2x3) glmCreateTestGTC(core_type_mat2x4) diff --git a/test/core/core_type_length_size.cpp b/test/core/core_type_length_size.cpp new file mode 100644 index 00000000..8edc58b2 --- /dev/null +++ b/test/core/core_type_length_size.cpp @@ -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 +#include + +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; +} +