Updated swizzle implementation, assert and static_assert draft

This commit is contained in:
Christophe Riccio 2011-01-14 20:26:58 +00:00
parent 21c1fa14a7
commit e145f7e389
3 changed files with 21 additions and 4 deletions

View File

@ -36,6 +36,7 @@ namespace glm
struct tvec4
{
enum ctor{null};
enum {_size = 4};
typedef T value_type;
typedef std::size_t size_type;
static size_type value_size();

View File

@ -26,9 +26,9 @@ namespace glm
//! GLM_GTC_swizzle extension
namespace swizzle{
template <typename T>
template <typename T, template <typename> class vecType>
T swizzle(
detail::tvec4<T> const & v,
vecType<T> const & v,
comp x);
template <typename T>
@ -46,6 +46,21 @@ namespace glm
detail::tvec4<T> const & v,
comp x, comp y, comp z, comp w);
template <typename T>
T& swizzle(
detail::tvec4<T> & v,
comp x);
template <typename T>
detail::tref2<T> swizzle(
detail::tvec4<T> & v,
comp x, comp y);
template <typename T>
detail::tref3<T> swizzle(
detail::tvec4<T> & v,
comp x, comp y, comp z);
template <typename T>
detail::tref4<T> swizzle(
detail::tvec4<T> & v,

View File

@ -2,13 +2,14 @@ namespace glm{
namespace gtc{
namespace swizzle
{
template <typename T>
template <typename T, template <typename> class vecType>
inline T swizzle
(
detail::tvec4<T> const & v,
vecType<T> const & v,
comp x
)
{
assert(int(x) < int(typename vecType<T>::_size));
return v[x];
}