diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 9b95bd0c..66d61102 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -726,6 +726,30 @@ # endif #endif//GLM_MESSAGE +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Length type + +// User defines: GLM_FORCE_SIZE_T_LENGTH + +namespace glm +{ +#if defined(GLM_FORCE_SIZE_T_LENGTH) + typedef std::size_t length_t; +#else + typedef int length_t; +#endif +}//namespace glm + +#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_FORCE_SIZE_T_LENGTH)) +# define GLM_MESSAGE_FORCE_SIZE_T_LENGTH +# if defined(GLM_FORCE_SIZE_T_LENGTH) +# pragma message("GLM: .length() returns glm::length_t, a typedef of std::size_t") +# else +# pragma message("GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification") +# pragma message("GLM: #define GLM_FORCE_SIZE_T_LENGTH for .length() to return a std::size_t") +# endif +#endif//GLM_MESSAGE + /////////////////////////////////////////////////////////////////////////////////////////////////// // Qualifiers diff --git a/glm/core/type_mat2x2.hpp b/glm/core/type_mat2x2.hpp index 54a3b152..19d82004 100644 --- a/glm/core/type_mat2x2.hpp +++ b/glm/core/type_mat2x2.hpp @@ -52,7 +52,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; public: // Implementation detail diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index c04d0443..5044e444 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x2::size_type tmat2x2::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x2::length() const { return 2; } diff --git a/glm/core/type_mat2x3.hpp b/glm/core/type_mat2x3.hpp index 169abbd7..dd6d49b0 100644 --- a/glm/core/type_mat2x3.hpp +++ b/glm/core/type_mat2x3.hpp @@ -52,7 +52,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; private: // Data diff --git a/glm/core/type_mat2x3.inl b/glm/core/type_mat2x3.inl index 89600262..1e901a13 100644 --- a/glm/core/type_mat2x3.inl +++ b/glm/core/type_mat2x3.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x3::size_type tmat2x3::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x3::length() const { return 2; } diff --git a/glm/core/type_mat2x4.hpp b/glm/core/type_mat2x4.hpp index cf2a7deb..32ca4ae8 100644 --- a/glm/core/type_mat2x4.hpp +++ b/glm/core/type_mat2x4.hpp @@ -52,7 +52,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; private: // Data diff --git a/glm/core/type_mat2x4.inl b/glm/core/type_mat2x4.inl index 7f4efd87..dec217a8 100644 --- a/glm/core/type_mat2x4.inl +++ b/glm/core/type_mat2x4.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x4::size_type tmat2x4::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x4::length() const { return 2; } diff --git a/glm/core/type_mat3x2.hpp b/glm/core/type_mat3x2.hpp index a70bea21..bd96605a 100644 --- a/glm/core/type_mat3x2.hpp +++ b/glm/core/type_mat3x2.hpp @@ -52,7 +52,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; private: // Data diff --git a/glm/core/type_mat3x2.inl b/glm/core/type_mat3x2.inl index 3d6a3ef6..5fafff25 100644 --- a/glm/core/type_mat3x2.inl +++ b/glm/core/type_mat3x2.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x2::size_type tmat3x2::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat3x2::length() const { return 3; } diff --git a/glm/core/type_mat3x3.hpp b/glm/core/type_mat3x3.hpp index 97c52969..8e242713 100644 --- a/glm/core/type_mat3x3.hpp +++ b/glm/core/type_mat3x3.hpp @@ -51,7 +51,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; public: /// Implementation detail diff --git a/glm/core/type_mat3x3.inl b/glm/core/type_mat3x3.inl index 3f800a4e..df41547f 100644 --- a/glm/core/type_mat3x3.inl +++ b/glm/core/type_mat3x3.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x3::size_type tmat3x3::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat3x3::length() const { return 3; } diff --git a/glm/core/type_mat3x4.hpp b/glm/core/type_mat3x4.hpp index 11d1e08f..8475294d 100644 --- a/glm/core/type_mat3x4.hpp +++ b/glm/core/type_mat3x4.hpp @@ -52,7 +52,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; private: // Data diff --git a/glm/core/type_mat3x4.inl b/glm/core/type_mat3x4.inl index 35782d63..c948d3ce 100644 --- a/glm/core/type_mat3x4.inl +++ b/glm/core/type_mat3x4.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x4::size_type tmat3x4::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat3x4::length() const { return 3; } diff --git a/glm/core/type_mat4x2.hpp b/glm/core/type_mat4x2.hpp index a90fa35f..faf79173 100644 --- a/glm/core/type_mat4x2.hpp +++ b/glm/core/type_mat4x2.hpp @@ -52,7 +52,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; private: // Data diff --git a/glm/core/type_mat4x2.inl b/glm/core/type_mat4x2.inl index 1455596c..d7648ce0 100644 --- a/glm/core/type_mat4x2.inl +++ b/glm/core/type_mat4x2.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x2::size_type tmat4x2::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat4x2::length() const { return 4; } diff --git a/glm/core/type_mat4x3.hpp b/glm/core/type_mat4x3.hpp index 18cc7a11..1452ab27 100644 --- a/glm/core/type_mat4x3.hpp +++ b/glm/core/type_mat4x3.hpp @@ -52,7 +52,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; private: // Data diff --git a/glm/core/type_mat4x3.inl b/glm/core/type_mat4x3.inl index 4cd53825..0c463518 100644 --- a/glm/core/type_mat4x3.inl +++ b/glm/core/type_mat4x3.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x3::size_type tmat4x3::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat4x3::length() const { return 4; } diff --git a/glm/core/type_mat4x4.hpp b/glm/core/type_mat4x4.hpp index 02b24fad..6036933c 100644 --- a/glm/core/type_mat4x4.hpp +++ b/glm/core/type_mat4x4.hpp @@ -55,7 +55,7 @@ namespace detail static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; public: /// Implementation detail diff --git a/glm/core/type_mat4x4.inl b/glm/core/type_mat4x4.inl index 33a01282..e4b3ac12 100644 --- a/glm/core/type_mat4x4.inl +++ b/glm/core/type_mat4x4.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x4::size_type tmat4x4::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat4x4::length() const { return 4; } diff --git a/glm/core/type_vec1.hpp b/glm/core/type_vec1.hpp index 4b1fe320..5480d3f0 100644 --- a/glm/core/type_vec1.hpp +++ b/glm/core/type_vec1.hpp @@ -61,7 +61,7 @@ namespace detail ////////////////////////////////////// // Helper - GLM_FUNC_DECL GLM_CONSTEXPR int length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; ////////////////////////////////////// // Data @@ -71,8 +71,8 @@ namespace detail ////////////////////////////////////// // Accesses - GLM_FUNC_DECL T & operator[](int i); - GLM_FUNC_DECL T const & operator[](int i) const; + GLM_FUNC_DECL T & operator[](length_t i); + GLM_FUNC_DECL T const & operator[](length_t i) const; ////////////////////////////////////// // Implicit basic constructors diff --git a/glm/core/type_vec1.inl b/glm/core/type_vec1.inl index 17943437..fdbdf61e 100644 --- a/glm/core/type_vec1.inl +++ b/glm/core/type_vec1.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR int tvec1::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec1::length() const { return 1; } @@ -39,14 +39,14 @@ namespace detail // Accesses template - GLM_FUNC_QUALIFIER T & tvec1::operator[](int i) + GLM_FUNC_QUALIFIER T & tvec1::operator[](length_t i) { assert(i >= 0 && i < this->length()); return (&x)[i]; } template - GLM_FUNC_QUALIFIER T const & tvec1::operator[](int i) const + GLM_FUNC_QUALIFIER T const & tvec1::operator[](length_t i) const { assert(i >= 0 && i < this->length()); return (&x)[i]; diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index 08649a3e..c093d649 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -62,7 +62,7 @@ namespace detail ////////////////////////////////////// // Helper - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; ////////////////////////////////////// // Data @@ -96,8 +96,8 @@ namespace detail ////////////////////////////////////// // Accesses - GLM_FUNC_DECL T & operator[](int i); - GLM_FUNC_DECL T const & operator[](int i) const; + GLM_FUNC_DECL T & operator[](length_t i); + GLM_FUNC_DECL T const & operator[](length_t i) const; ////////////////////////////////////// // Implicit basic constructors diff --git a/glm/core/type_vec2.inl b/glm/core/type_vec2.inl index d690e39b..420f60d1 100644 --- a/glm/core/type_vec2.inl +++ b/glm/core/type_vec2.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2::size_type tvec2::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec2::length() const { return 2; } @@ -39,14 +39,14 @@ namespace detail // Accesses template - GLM_FUNC_QUALIFIER T & tvec2::operator[](int i) + GLM_FUNC_QUALIFIER T & tvec2::operator[](length_t i) { assert(i >= 0 && i < this->length()); return (&x)[i]; } template - GLM_FUNC_QUALIFIER T const & tvec2::operator[](int i) const + GLM_FUNC_QUALIFIER T const & tvec2::operator[](length_t i) const { assert(i >= 0 && i < this->length()); return (&x)[i]; diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index 40343504..d73e7639 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -62,7 +62,7 @@ namespace detail ////////////////////////////////////// // Helper - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; ////////////////////////////////////// // Data @@ -97,8 +97,8 @@ namespace detail ////////////////////////////////////// // Accesses - GLM_FUNC_DECL T & operator[](int i); - GLM_FUNC_DECL T const & operator[](int i) const; + GLM_FUNC_DECL T & operator[](length_t i); + GLM_FUNC_DECL T const & operator[](length_t i) const; ////////////////////////////////////// // Implicit basic constructors diff --git a/glm/core/type_vec3.inl b/glm/core/type_vec3.inl index a61b075b..60b3ba6d 100644 --- a/glm/core/type_vec3.inl +++ b/glm/core/type_vec3.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec3::size_type tvec3::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec3::length() const { return 3; } @@ -39,14 +39,14 @@ namespace detail // Accesses template - GLM_FUNC_QUALIFIER T & tvec3::operator[](int i) + GLM_FUNC_QUALIFIER T & tvec3::operator[](length_t i) { assert(i >= 0 && i < this->length()); return (&x)[i]; } template - GLM_FUNC_QUALIFIER T const & tvec3::operator[](int i) const + GLM_FUNC_QUALIFIER T const & tvec3::operator[](length_t i) const { assert(i >= 0 && i < this->length()); return (&x)[i]; diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index e044b807..39192c3a 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -63,7 +63,7 @@ namespace detail ////////////////////////////////////// // Helper - GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; ////////////////////////////////////// // Data @@ -99,8 +99,8 @@ namespace detail ////////////////////////////////////// // Accesses - GLM_FUNC_DECL T & operator[](int i); - GLM_FUNC_DECL T const & operator[](int i) const; + GLM_FUNC_DECL T & operator[](length_t i); + GLM_FUNC_DECL T const & operator[](length_t i) const; ////////////////////////////////////// // Implicit basic constructors diff --git a/glm/core/type_vec4.inl b/glm/core/type_vec4.inl index 69186722..d6688a2e 100644 --- a/glm/core/type_vec4.inl +++ b/glm/core/type_vec4.inl @@ -30,7 +30,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec4::size_type tvec4::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec4::length() const { return 4; } @@ -39,14 +39,14 @@ namespace detail // Accesses template - GLM_FUNC_QUALIFIER T & tvec4::operator[](int i) + GLM_FUNC_QUALIFIER T & tvec4::operator[](length_t i) { assert(i >= 0 && i < this->length()); return (&x)[i]; } template - GLM_FUNC_QUALIFIER T const & tvec4::operator[](int i) const + GLM_FUNC_QUALIFIER T const & tvec4::operator[](length_t i) const { assert(i >= 0 && i < this->length()); return (&x)[i]; diff --git a/readme.txt b/readme.txt index 749605ac..e36407e7 100644 --- a/readme.txt +++ b/readme.txt @@ -56,6 +56,7 @@ GLM 0.9.5.0: 2013-12-25 - Clean up compiler detection code for unsupported compilers - Uses C++ casts - Fixed .length() that should return a int and not a size_t +- Added GLM_FORCE_SIZE_T_LENGTH and glm::length_t - Removed unnecessary conversions - Optimized packing and unpacking functions - Removed the normalization of the up argument of lookAt function (#114)