Browse Source

Added per feature headers and added length_t and GLM_FORCE_SIZE_T_LENGTH

Christophe Riccio 12 years ago
parent
commit
ca2463d5f2

+ 24 - 0
glm/core/setup.hpp

@@ -726,6 +726,30 @@
 #	endif
 #	endif
 #endif//GLM_MESSAGE
 #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
 // Qualifiers
 
 

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	public:
 		// Implementation detail
 		// Implementation detail

+ 1 - 1
glm/core/type_mat2x2.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x2<T, P>::size_type tmat2x2<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x2<T, P>::length() const
 	{
 	{
 		return 2;
 		return 2;
 	}
 	}

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	private:
 		// Data 
 		// Data 

+ 1 - 1
glm/core/type_mat2x3.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x3<T, P>::size_type tmat2x3<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x3<T, P>::length() const
 	{
 	{
 		return 2;
 		return 2;
 	}
 	}

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	private:
 		// Data 
 		// Data 

+ 1 - 1
glm/core/type_mat2x4.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x4<T, P>::size_type tmat2x4<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x4<T, P>::length() const
 	{
 	{
 		return 2;
 		return 2;
 	}
 	}

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	private:
 		// Data
 		// Data

+ 1 - 1
glm/core/type_mat3x2.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x2<T, P>::size_type tmat3x2<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat3x2<T, P>::length() const
 	{
 	{
 		return 3;
 		return 3;
 	}
 	}

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	public:
 		/// Implementation detail
 		/// Implementation detail

+ 1 - 1
glm/core/type_mat3x3.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x3<T, P>::size_type tmat3x3<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat3x3<T, P>::length() const
 	{
 	{
 		return 3;
 		return 3;
 	}
 	}

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	private:
 		// Data 
 		// Data 

+ 1 - 1
glm/core/type_mat3x4.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x4<T, P>::size_type tmat3x4<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat3x4<T, P>::length() const
 	{
 	{
 		return 3;
 		return 3;
 	}
 	}

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	private:
 		// Data 
 		// Data 

+ 1 - 1
glm/core/type_mat4x2.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x2<T, P>::size_type tmat4x2<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat4x2<T, P>::length() const
 	{
 	{
 		return 4;
 		return 4;
 	}
 	}

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	private:
 		// Data 
 		// Data 

+ 1 - 1
glm/core/type_mat4x3.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x3<T, P>::size_type tmat4x3<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat4x3<T, P>::length() const
 	{
 	{
 		return 4;
 		return 4;
 	}
 	}

+ 1 - 1
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 col_size();
 		static GLM_FUNC_DECL size_type row_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:
 	public:
 		/// Implementation detail
 		/// Implementation detail

+ 1 - 1
glm/core/type_mat4x4.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x4<T, P>::size_type tmat4x4<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat4x4<T, P>::length() const
 	{
 	{
 		return 4;
 		return 4;
 	}
 	}

+ 3 - 3
glm/core/type_vec1.hpp

@@ -61,7 +61,7 @@ namespace detail
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Helper
 		// Helper
 
 
-		GLM_FUNC_DECL GLM_CONSTEXPR int length() const;
+		GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
 
 
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Data
 		// Data
@@ -71,8 +71,8 @@ namespace detail
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Accesses
 		// 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
 		// Implicit basic constructors

+ 3 - 3
glm/core/type_vec1.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR int tvec1<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec1<T, P>::length() const
 	{
 	{
 		return 1;
 		return 1;
 	}
 	}
@@ -39,14 +39,14 @@ namespace detail
 	// Accesses
 	// Accesses
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER T & tvec1<T, P>::operator[](int i)
+	GLM_FUNC_QUALIFIER T & tvec1<T, P>::operator[](length_t i)
 	{
 	{
 		assert(i >= 0 && i < this->length());
 		assert(i >= 0 && i < this->length());
 		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[](int i) const
+	GLM_FUNC_QUALIFIER T const & tvec1<T, P>::operator[](length_t i) const
 	{
 	{
 		assert(i >= 0 && i < this->length());
 		assert(i >= 0 && i < this->length());
 		return (&x)[i];
 		return (&x)[i];

+ 3 - 3
glm/core/type_vec2.hpp

@@ -62,7 +62,7 @@ namespace detail
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Helper
 		// Helper
 
 
-		GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
+		GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
 
 
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Data
 		// Data
@@ -96,8 +96,8 @@ namespace detail
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Accesses
 		// 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
 		// Implicit basic constructors

+ 3 - 3
glm/core/type_vec2.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2<T, P>::size_type tvec2<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec2<T, P>::length() const
 	{
 	{
 		return 2;
 		return 2;
 	}
 	}
@@ -39,14 +39,14 @@ namespace detail
 	// Accesses
 	// Accesses
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](int i)
+	GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](length_t i)
 	{
 	{
 		assert(i >= 0 && i < this->length());
 		assert(i >= 0 && i < this->length());
 		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[](int i) const
+	GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](length_t i) const
 	{
 	{
 		assert(i >= 0 && i < this->length());
 		assert(i >= 0 && i < this->length());
 		return (&x)[i];
 		return (&x)[i];

+ 3 - 3
glm/core/type_vec3.hpp

@@ -62,7 +62,7 @@ namespace detail
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Helper
 		// Helper
 
 
-		GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
+		GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
 
 
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Data
 		// Data
@@ -97,8 +97,8 @@ namespace detail
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Accesses
 		// 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
 		// Implicit basic constructors

+ 3 - 3
glm/core/type_vec3.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec3<T, P>::size_type tvec3<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec3<T, P>::length() const
 	{
 	{
 		return 3;
 		return 3;
 	}
 	}
@@ -39,14 +39,14 @@ namespace detail
 	// Accesses
 	// Accesses
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER T & tvec3<T, P>::operator[](int i)
+	GLM_FUNC_QUALIFIER T & tvec3<T, P>::operator[](length_t i)
 	{
 	{
 		assert(i >= 0 && i < this->length());
 		assert(i >= 0 && i < this->length());
 		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[](int i) const
+	GLM_FUNC_QUALIFIER T const & tvec3<T, P>::operator[](length_t i) const
 	{
 	{
 		assert(i >= 0 && i < this->length());
 		assert(i >= 0 && i < this->length());
 		return (&x)[i];
 		return (&x)[i];

+ 3 - 3
glm/core/type_vec4.hpp

@@ -63,7 +63,7 @@ namespace detail
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Helper
 		// Helper
 
 
-		GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
+		GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
 
 
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Data
 		// Data
@@ -99,8 +99,8 @@ namespace detail
 		//////////////////////////////////////
 		//////////////////////////////////////
 		// Accesses
 		// 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
 		// Implicit basic constructors

+ 3 - 3
glm/core/type_vec4.inl

@@ -30,7 +30,7 @@ namespace glm{
 namespace detail
 namespace detail
 {
 {
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec4<T, P>::size_type tvec4<T, P>::length() const
+	GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec4<T, P>::length() const
 	{
 	{
 		return 4;
 		return 4;
 	}
 	}
@@ -39,14 +39,14 @@ namespace detail
 	// Accesses
 	// Accesses
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER T & tvec4<T, P>::operator[](int i)
+	GLM_FUNC_QUALIFIER T & tvec4<T, P>::operator[](length_t i)
 	{
 	{
 		assert(i >= 0 && i < this->length());
 		assert(i >= 0 && i < this->length());
 		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[](int i) const
+	GLM_FUNC_QUALIFIER T const & tvec4<T, P>::operator[](length_t i) const
 	{
 	{
 		assert(i >= 0 && i < this->length());
 		assert(i >= 0 && i < this->length());
 		return (&x)[i];
 		return (&x)[i];

+ 1 - 0
readme.txt

@@ -56,6 +56,7 @@ GLM 0.9.5.0: 2013-12-25
 - Clean up compiler detection code for unsupported compilers
 - Clean up compiler detection code for unsupported compilers
 - Uses C++ casts
 - Uses C++ casts
 - Fixed .length() that should return a int and not a size_t
 - 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
 - Removed unnecessary conversions
 - Optimized packing and unpacking functions
 - Optimized packing and unpacking functions
 - Removed the normalization of the up argument of lookAt function (#114)
 - Removed the normalization of the up argument of lookAt function (#114)