Added per feature headers and added length_t and GLM_FORCE_SIZE_T_LENGTH

This commit is contained in:
Christophe Riccio 2013-12-24 06:43:25 +01:00
parent 5ef31a6e18
commit ca2463d5f2
28 changed files with 67 additions and 42 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 & operator[](length_t i);
GLM_FUNC_DECL T const & operator[](int i) const; GLM_FUNC_DECL T const & operator[](length_t i) const;
////////////////////////////////////// //////////////////////////////////////
// Implicit basic constructors // Implicit basic constructors

View File

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

View File

@ -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 & operator[](length_t i);
GLM_FUNC_DECL T const & operator[](int i) const; GLM_FUNC_DECL T const & operator[](length_t i) const;
////////////////////////////////////// //////////////////////////////////////
// Implicit basic constructors // Implicit basic constructors

View File

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

View File

@ -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 & operator[](length_t i);
GLM_FUNC_DECL T const & operator[](int i) const; GLM_FUNC_DECL T const & operator[](length_t i) const;
////////////////////////////////////// //////////////////////////////////////
// Implicit basic constructors // Implicit basic constructors

View File

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

View File

@ -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 & operator[](length_t i);
GLM_FUNC_DECL T const & operator[](int i) const; GLM_FUNC_DECL T const & operator[](length_t i) const;
////////////////////////////////////// //////////////////////////////////////
// Implicit basic constructors // Implicit basic constructors

View File

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

View File

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