forked from g-truc/glm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
406 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/// @ref gtx_range | ||
/// @file glm/gtx/iteration.hpp | ||
/// | ||
/// @defgroup gtx_iteration GLM_GTX_iteration | ||
/// @ingroup gtx | ||
/// | ||
/// Include <glm/gtx/iteration.hpp> to use the features of this extension. | ||
/// | ||
/// Defines begin and end for vectors, matrices and quaternions useful for range based for loop construct | ||
|
||
#pragma once | ||
|
||
// Dependencies | ||
#include "../detail/setup.hpp" | ||
#include "../detail/qualifier.hpp" | ||
|
||
#ifndef GLM_ENABLE_EXPERIMENTAL | ||
# error "GLM: GLM_GTX_iteration is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it." | ||
#elif GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) | ||
# pragma message("GLM: GLM_GTX_iteration extension included") | ||
#endif | ||
|
||
#include <iterator> | ||
|
||
namespace glm | ||
{ | ||
/// @addtogroup gtx_iteration | ||
/// @{ | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL T* begin(vec<L, T, Q>& v); | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL T* begin(mat<C, R, T, Q>& m); | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL T* begin(qua<T, Q>& q); | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL const T* begin(const vec<L, T, Q>& v); | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL const T* begin(const mat<C, R, T, Q>& m); | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL const T* begin(const qua<T, Q>& q); | ||
|
||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL T* end(vec<L, T, Q>& v); | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL T* end(mat<C, R, T, Q>& m); | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL T* end(qua<T, Q>& q); | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL const T* end(const vec<L, T, Q>& v); | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL const T* end(const mat<C, R, T, Q>& m); | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL const T* end(const qua<T, Q>& q); | ||
|
||
// Reverse iteration | ||
// rbegin,rend | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<T*> rbegin(vec<L, T, Q>& v); | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<T*> rbegin(mat<C, R, T, Q>& m); | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<T*> rbegin(qua<T, Q>& q); | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<const T*> rbegin(const vec<L, T, Q>& v); | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<const T*> rbegin(const mat<C, R, T, Q>& m); | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<const T*> rbegin(const qua<T, Q>& q); | ||
|
||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<T*> rend(vec<L, T, Q>& v); | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<T*> rend(mat<C, R, T, Q>& m); | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<T*> rend(qua<T, Q>& q); | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<const T*> rend(const vec<L, T, Q>& v); | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<const T*> rend(const mat<C, R, T, Q>& m); | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_DECL std::reverse_iterator<const T*> rend(const qua<T, Q>& q); | ||
|
||
|
||
/// @} | ||
}//namespace glm | ||
|
||
#include "iteration.inl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
namespace glm | ||
{ | ||
/* | ||
namespace details { | ||
template<typename T, glm::length_t L> | ||
struct known_length_iterator; | ||
} | ||
*/ | ||
|
||
/// @addtogroup gtx_range | ||
/// @{ | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER T* begin(vec<L,T,Q>& v) { | ||
return &v.x; | ||
} | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER T* begin(mat<C,R,T,Q>& m) { | ||
return &m[0].x; | ||
} | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER T* begin(qua<T,Q>& q) { | ||
return &q[0]; | ||
} | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER const T* begin(const vec<L,T,Q>& v) { | ||
return &v.x; | ||
} | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER const T* begin(const mat<C,R,T,Q>& m) { | ||
return &m[0].x; | ||
} | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER const T* begin(const qua<T,Q>& q) { | ||
return &q[0]; | ||
} | ||
|
||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER T* end(vec<L,T,Q>& v) { | ||
return (&v.x) + L; | ||
} | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER T* end(mat<C,R,T,Q>& m) { | ||
return (&m[0].x) + C*R; | ||
} | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER T* end(qua<T,Q>& q) { | ||
return (&q[0]) + 4; | ||
} | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER const T* end(const vec<L,T,Q>& v) { | ||
return (&v.x) + L; | ||
} | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER const T* end(const mat<C,R,T,Q>& m) { | ||
return (&m[0].x) + C*R; | ||
} | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER const T* end(const qua<T,Q>& q) { | ||
return (&q[0]) + 4; | ||
} | ||
|
||
// Reverse iteration | ||
// rbegin,rend | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<T*> rbegin(vec<L,T,Q>& v) { | ||
return std::reverse_iterator<T*>(end(v)); | ||
} | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<T*> rbegin(mat<C,R,T,Q>& m) { | ||
return std::reverse_iterator<T*>(end(m)); | ||
} | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<T*> rbegin(qua<T,Q>& q) { | ||
return std::reverse_iterator<T*>(end(q)); | ||
} | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<const T*> rbegin(const vec<L,T,Q>& v) { | ||
return std::reverse_iterator<const T*>(end(v)); | ||
} | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<const T*> rbegin(const mat<C,R,T,Q>& m) { | ||
return std::reverse_iterator<const T*>(end(m)); | ||
} | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<const T*> rbegin(const qua<T,Q>& q) { | ||
return std::reverse_iterator<const T*>(end(q)); | ||
} | ||
|
||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<T*> rend(vec<L,T,Q>& v) { | ||
return std::reverse_iterator<T*>(begin(v)); | ||
} | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<T*> rend(mat<C,R,T,Q>& m) { | ||
return std::reverse_iterator<T*>(begin(m)); | ||
} | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<T*> rend(qua<T,Q>& q) { | ||
return std::reverse_iterator<T*>(begin(q)); | ||
} | ||
template<length_t L,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<const T*> rend(const vec<L,T,Q>& v) { | ||
return std::reverse_iterator<const T*>(begin(v)); | ||
} | ||
template<length_t C,length_t R,typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<const T*> rend(const mat<C,R,T,Q>& m) { | ||
return std::reverse_iterator<const T*>(begin(m)); | ||
} | ||
template<typename T,qualifier Q> | ||
GLM_CONSTEXPR GLM_FUNC_QUALIFIER std::reverse_iterator<const T*> rend(const qua<T,Q>& q) { | ||
return std::reverse_iterator<const T*>(begin(q)); | ||
} | ||
|
||
|
||
/// @} | ||
}//namespace glm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.