Merge branch 'type_trait'

master
Christophe Riccio ago%!(EXTRA string=9 years)
commit 07a5d27047
  1. 4
      .gitignore
  2. 17
      glm/gtx/io.hpp
  3. 555
      glm/gtx/io.inl
  4. 209
      glm/gtx/type_trait.hpp
  5. 29
      test/gtx/gtx_io.cpp
  6. 67
      test/gtx/gtx_type_trait.cpp

4
.gitignore vendored

@ -48,3 +48,7 @@ Makefile
# Misc. # Misc.
*.log *.log
# local build(s)
build*

@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net) /// OpenGL Mathematics (glm.g-truc.net)
/// ///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) /// Copyright (c) 2005 - 2016 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy /// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal /// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights /// in the Software without restriction, including without limitation the rights
@ -26,10 +26,11 @@
/// ///
/// @ref gtx_io /// @ref gtx_io
/// @file glm/gtx/io.hpp /// @file glm/gtx/io.hpp
/// @date 2013-11-22 / 2014-11-25 /// @date 2013-11-22 / 2016-03-14
/// @author Jan P Springer (regnirpsj@gmail.com) /// @author Jan P Springer (regnirpsj@gmail.com)
/// ///
/// @see core (dependence) /// @see core (dependence)
/// @see gtc_matrix_access (dependence)
/// @see gtc_quaternion (dependence) /// @see gtc_quaternion (dependence)
/// ///
/// @defgroup gtx_io GLM_GTX_io /// @defgroup gtx_io GLM_GTX_io
@ -215,16 +216,8 @@ namespace glm
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x4<T,P> const&); GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x4<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P> template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<( GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr> &,
std::basic_ostream<CTy,CTr> &, std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const &);
std::pair<tmat4x4<T,P> const,
tmat4x4<T,P> const> const &);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<(
std::basic_ostream<CTy,CTr> &,
std::pair<tmat4x4<T,P>,
tmat4x4<T,P> > const &);
/// @} /// @}
}//namespace glm }//namespace glm

@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net) /// OpenGL Mathematics (glm.g-truc.net)
/// ///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) /// Copyright (c) 2005 - 2016 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy /// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal /// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights /// in the Software without restriction, including without limitation the rights
@ -26,56 +26,56 @@
/// ///
/// @ref gtx_io /// @ref gtx_io
/// @file glm/gtx/io.inl /// @file glm/gtx/io.inl
/// @date 2013-11-22 / 2014-11-25 /// @date 2013-11-22 / 2016-03-14
/// @author Jan P Springer (regnirpsj@gmail.com) /// @author Jan P Springer (regnirpsj@gmail.com)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#include <iomanip> // std::setfill<>, std::fixed, std::setprecision, std::right, std::setw #include <iomanip> // std::fixed, std::setfill<>, std::setprecision, std::right, std::setw
#include <ostream> // std::basic_ostream<> #include <ostream> // std::basic_ostream<>
#include "../gtc/matrix_access.hpp" // glm::col, glm::row
#include "../gtx/type_trait.hpp" // glm::type<>
namespace glm{ namespace glm{
namespace io namespace io
{ {
template <typename CTy> template <typename CTy>
/* explicit */ GLM_FUNC_QUALIFIER GLM_FUNC_QUALIFIER format_punct<CTy>::format_punct(size_t a)
format_punct<CTy>::format_punct(size_t a) : std::locale::facet(a)
: std::locale::facet(a), , formatted(true)
formatted (true), , precision(3)
precision (3), , width(1 + 4 + 1 + precision)
width (1 + 4 + 1 + precision), , separator(',')
separator (','), , delim_left('[')
delim_left ('['), , delim_right(']')
delim_right (']'), , space(' ')
space (' '), , newline('\n')
newline ('\n'), , order(column_major)
order (row_major)
{} {}
template <typename CTy> template <typename CTy>
/* explicit */ GLM_FUNC_QUALIFIER GLM_FUNC_QUALIFIER format_punct<CTy>::format_punct(format_punct const& a)
format_punct<CTy>::format_punct(format_punct const& a) : std::locale::facet(0)
: std::locale::facet(0), , formatted(a.formatted)
formatted (a.formatted), , precision(a.precision)
precision (a.precision), , width(a.width)
width (a.width), , separator(a.separator)
separator (a.separator), , delim_left(a.delim_left)
delim_left (a.delim_left), , delim_right(a.delim_right)
delim_right (a.delim_right), , space(a.space)
space (a.space), , newline(a.newline)
newline (a.newline), , order(a.order)
order (a.order)
{} {}
template <typename CTy> std::locale::id format_punct<CTy>::id; template <typename CTy> std::locale::id format_punct<CTy>::id;
template <typename CTy, typename CTr> template <typename CTy, typename CTr>
/* explicit */ GLM_FUNC_QUALIFIER basic_state_saver<CTy,CTr>::basic_state_saver(std::basic_ios<CTy,CTr>& a) GLM_FUNC_QUALIFIER basic_state_saver<CTy, CTr>::basic_state_saver(std::basic_ios<CTy, CTr>& a)
: state_ (a), : state_(a)
flags_ (a.flags()), , flags_(a.flags())
precision_(a.precision()), , precision_(a.precision())
width_ (a.width()), , width_(a.width())
fill_ (a.fill()), , fill_(a.fill())
locale_ (a.getloc()) , locale_(a.getloc())
{} {}
template <typename CTy, typename CTr> template <typename CTy, typename CTr>
@ -89,7 +89,7 @@ namespace io
} }
template <typename CTy, typename CTr> template <typename CTy, typename CTr>
/* explicit */ GLM_FUNC_QUALIFIER basic_format_saver<CTy,CTr>::basic_format_saver(std::basic_ios<CTy,CTr>& a) GLM_FUNC_QUALIFIER basic_format_saver<CTy, CTr>::basic_format_saver(std::basic_ios<CTy, CTr>& a)
: bss_(a) : bss_(a)
{ {
a.imbue(std::locale(a.getloc(), new format_punct<CTy>(get_facet<format_punct<CTy> >(a)))); a.imbue(std::locale(a.getloc(), new format_punct<CTy>(get_facet<format_punct<CTy> >(a))));
@ -100,16 +100,16 @@ namespace io
basic_format_saver<CTy, CTr>::~basic_format_saver() basic_format_saver<CTy, CTr>::~basic_format_saver()
{} {}
/* explicit */ GLM_FUNC_QUALIFIER precision::precision(unsigned a) GLM_FUNC_QUALIFIER precision::precision(unsigned a)
: value(a) : value(a)
{} {}
/* explicit */ GLM_FUNC_QUALIFIER width::width(unsigned a) GLM_FUNC_QUALIFIER width::width(unsigned a)
: value(a) : value(a)
{} {}
template <typename CTy> template <typename CTy>
/* explicit */ GLM_FUNC_QUALIFIER delimeter<CTy>::delimeter(CTy a, CTy b, CTy c) GLM_FUNC_QUALIFIER delimeter<CTy>::delimeter(CTy a, CTy b, CTy c)
: value() : value()
{ {
value[0] = a; value[0] = a;
@ -117,17 +117,15 @@ namespace io
value[2] = c; value[2] = c;
} }
/* explicit */ GLM_FUNC_QUALIFIER GLM_FUNC_QUALIFIER order::order(order_type a)
order::order(order_type a)
: value(a) : value(a)
{} {}
template <typename FTy, typename CTy, typename CTr> template <typename FTy, typename CTy, typename CTr>
GLM_FUNC_QUALIFIER FTy const& get_facet(std::basic_ios<CTy, CTr>& ios) GLM_FUNC_QUALIFIER FTy const& get_facet(std::basic_ios<CTy, CTr>& ios)
{ {
if (!std::has_facet<FTy>(ios.getloc())) { if(!std::has_facet<FTy>(ios.getloc()))
ios.imbue(std::locale(ios.getloc(), new FTy)); ios.imbue(std::locale(ios.getloc(), new FTy));
}
return std::use_facet<FTy>(ios.getloc()); return std::use_facet<FTy>(ios.getloc());
} }
@ -136,7 +134,6 @@ namespace io
GLM_FUNC_QUALIFIER std::basic_ios<CTy, CTr>& formatted(std::basic_ios<CTy, CTr>& ios) GLM_FUNC_QUALIFIER std::basic_ios<CTy, CTr>& formatted(std::basic_ios<CTy, CTr>& ios)
{ {
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(ios)).formatted = true; const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(ios)).formatted = true;
return ios; return ios;
} }
@ -144,7 +141,6 @@ namespace io
GLM_FUNC_QUALIFIER std::basic_ios<CTy, CTr>& unformatted(std::basic_ios<CTy, CTr>& ios) GLM_FUNC_QUALIFIER std::basic_ios<CTy, CTr>& unformatted(std::basic_ios<CTy, CTr>& ios)
{ {
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(ios)).formatted = false; const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(ios)).formatted = false;
return ios; return ios;
} }
@ -152,7 +148,6 @@ namespace io
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, precision const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, precision const& a)
{ {
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).precision = a.value; const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).precision = a.value;
return os; return os;
} }
@ -160,12 +155,11 @@ namespace io
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, width const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, width const& a)
{ {
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).width = a.value; const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).width = a.value;
return os; return os;
} }
template <typename CTy, typename CTr> template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, delimeter<CTy> const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, delimeter<CTy> const& a)
{ {
format_punct<CTy> & fmt(const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os))); format_punct<CTy> & fmt(const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)));
@ -180,13 +174,15 @@ namespace io
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, order const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, order const& a)
{ {
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).order = a.value; const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).order = a.value;
return os; return os;
} }
} // namespace io } // namespace io
template <typename CTy, typename CTr, typename T, precision P> namespace detail
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tquat<T,P> const& a) {
template <typename CTy, typename CTr, template <typename, precision> class V, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
print_vector_on(std::basic_ostream<CTy, CTr>& os, V<T,P> const& a)
{ {
typename std::basic_ostream<CTy, CTr>::sentry const cerberus(os); typename std::basic_ostream<CTy, CTr>::sentry const cerberus(os);
@ -194,125 +190,74 @@ namespace io
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
length_t const& components(type<V, T, P>::components);
if(fmt.formatted) if(fmt.formatted)
{ {
io::basic_state_saver<CTy> const bss(os); io::basic_state_saver<CTy> const bss(os);
os << std::fixed os << std::fixed << std::right << std::setprecision(fmt.precision) << std::setfill(fmt.space) << fmt.delim_left;
<< std::right
<< std::setprecision(fmt.precision) for(length_t i(0); i < components; ++i)
<< std::setfill(fmt.space)
<< fmt.delim_left
<< std::setw(fmt.width) << a.w << fmt.separator
<< std::setw(fmt.width) << a.x << fmt.separator
<< std::setw(fmt.width) << a.y << fmt.separator
<< std::setw(fmt.width) << a.z
<< fmt.delim_right;
}
else
{ {
os << a.w << fmt.space << a.x << fmt.space << a.y << fmt.space << a.z; os << std::setw(fmt.width) << a[i];
} if(components-1 != i)
os << fmt.separator;
} }
return os; os << fmt.delim_right;
} }
else
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec1<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); for(length_t i(0); i < components; ++i)
if(cerberus)
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); os << a[i];
if(fmt.formatted) if(components-1 != i)
{ os << fmt.space;
io::basic_state_saver<CTy> const bss(os);
os << std::fixed
<< std::right
<< std::setprecision(fmt.precision)
<< std::setfill(fmt.space)
<< fmt.delim_left
<< std::setw(fmt.width) << a.x
<< fmt.delim_right;
} }
else
{
os << a.x;
} }
} }
return os; return os;
} }
}//namespace detail
template <typename CTy, typename CTr, typename T, precision P> template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec2<T,P> const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tquat<T,P> const& a)
{
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
if(cerberus)
{
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
if(fmt.formatted)
{ {
io::basic_state_saver<CTy> const bss(os); return detail::print_vector_on(os, a);
os << std::fixed
<< std::right
<< std::setprecision(fmt.precision)
<< std::setfill(fmt.space)
<< fmt.delim_left
<< std::setw(fmt.width) << a.x << fmt.separator
<< std::setw(fmt.width) << a.y
<< fmt.delim_right;
} }
else
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec1<T,P> const& a)
{ {
os << a.x << fmt.space << a.y; return detail::print_vector_on(os, a);
}
} }
return os; template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec2<T,P> const& a)
{
return detail::print_vector_on(os, a);
} }
template <typename CTy, typename CTr, typename T, precision P> template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec3<T,P> const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec3<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); return detail::print_vector_on(os, a);
if(cerberus)
{
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
if(fmt.formatted)
{
io::basic_state_saver<CTy> const bss(os);
os << std::fixed
<< std::right
<< std::setprecision(fmt.precision)
<< std::setfill(fmt.space)
<< fmt.delim_left
<< std::setw(fmt.width) << a.x << fmt.separator
<< std::setw(fmt.width) << a.y << fmt.separator
<< std::setw(fmt.width) << a.z
<< fmt.delim_right;
}
else
{
os << a.x << fmt.space << a.y << fmt.space << a.z;
}
}
return os;
} }
template <typename CTy, typename CTr, typename T, precision P> template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec4<T,P> const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec4<T,P> const& a)
{
return detail::print_vector_on(os, a);
}
namespace detail
{
template <typename CTy, typename CTr, template <typename, precision> class M, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
print_matrix_on(std::basic_ostream<CTy, CTr>& os, M<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
@ -320,322 +265,190 @@ namespace io
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
length_t const& cols(type<M, T, P>::cols);
length_t const& rows(type<M, T, P>::rows);
if(fmt.formatted) if(fmt.formatted)
{ {
io::basic_state_saver<CTy> const bss(os); os << fmt.newline << fmt.delim_left;
os << std::fixed switch(fmt.order)
<< std::right
<< std::setprecision(fmt.precision)
<< std::setfill(fmt.space)
<< fmt.delim_left
<< std::setw(fmt.width) << a.x << fmt.separator
<< std::setw(fmt.width) << a.y << fmt.separator
<< std::setw(fmt.width) << a.z << fmt.separator
<< std::setw(fmt.width) << a.w
<< fmt.delim_right;
}
else
{ {
os << a.x << fmt.space << a.y << fmt.space << a.z << fmt.space << a.w; case io::column_major:
}
}
return os;
}
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x2<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); for(length_t i(0); i < rows; ++i)
if(cerberus)
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); if (0 != i)
tmat2x2<T,P> m(a); os << fmt.space;
if(io::row_major == fmt.order) os << row(a, i);
m = transpose(a);
if(fmt.formatted) if(rows-1 != i)
{ os << fmt.newline;
os << fmt.newline
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.delim_right;
} }
else
{
os << m[0] << fmt.space << m[1];
}
}
return os;
} }
break;
template <typename CTy, typename CTr, typename T, precision P> case io::row_major:
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x3<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); for(length_t i(0); i < cols; ++i)
if(cerberus)
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); if(0 != i)
tmat3x2<T,P> m(a); os << fmt.space;
if(io::row_major == fmt.order) os << column(a, i);
m = transpose(a);
if(fmt.formatted) if(cols-1 != i)
{ os << fmt.newline;
os << fmt.newline
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.newline
<< fmt.space << m[2] << fmt.delim_right;
} }
else
{
os << m[0] << fmt.space << m[1] << fmt.space << m[2];
} }
break;
} }
return os; os << fmt.delim_right;
} }
else
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x4<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); switch (fmt.order)
if(cerberus)
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); case io::column_major:
tmat4x2<T,P> m(a);
if(io::row_major == fmt.order)
m = transpose(a);
if(fmt.formatted)
{ {
os << fmt.newline for(length_t i(0); i < cols; ++i)
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.newline
<< fmt.space << m[2] << fmt.newline
<< fmt.space << m[3] << fmt.delim_right;
}
else
{ {
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; os << column(a, i);
}
}
return os; if(cols - 1 != i)
os << fmt.space;
}
} }
break;
template <typename CTy, typename CTr, typename T, precision P> case io::row_major:
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x2<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); for (length_t i(0); i < rows; ++i)
if(cerberus)
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); os << row(a, i);
tmat2x3<T,P> m(a);
if(io::row_major == fmt.order) if (rows-1 != i)
m = transpose(a); os << fmt.space;
}
if(fmt.formatted) }
{ break;
os << fmt.newline
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.delim_right;
} }
else
{
os << m[0] << fmt.space << m[1];
} }
} }
return os; return os;
} }
}//namespace detail
template <typename CTy, typename CTr, typename T, precision P> template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x3<T,P> const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x2<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); return detail::print_matrix_on(os, a);
}
if(cerberus) template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x3<T,P> const& a)
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); return detail::print_matrix_on(os, a);
tmat3x3<T,P> m(a); }
if(io::row_major == fmt.order)
m = transpose(a);
if(fmt.formatted) template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x4<T,P> const& a)
{ {
os << fmt.newline return detail::print_matrix_on(os, a);
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.newline
<< fmt.space << m[2] << fmt.delim_right;
} }
else
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x2<T,P> const& a)
{ {
os << m[0] << fmt.space << m[1] << fmt.space << m[2]; return detail::print_matrix_on(os, a);
}
} }
return os; template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x3<T,P> const& a)
{
return detail::print_matrix_on(os, a);
} }
template <typename CTy, typename CTr, typename T, precision P> template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x4<T,P> const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x4<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); return detail::print_matrix_on(os, a);
if(cerberus)
{
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
tmat4x3<T,P> m(a);
if(io::row_major == fmt.order)
m = transpose(a);
if (fmt.formatted)
{
os << fmt.newline
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.newline
<< fmt.space << m[2] << fmt.newline
<< fmt.space << m[3] << fmt.delim_right;
}
else
{
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3];
}
}
return os;
} }
template <typename CTy, typename CTr, typename T, precision P> template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x2<T,P> const& a) GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x2<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); return detail::print_matrix_on(os, a);
if(cerberus)
{
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
tmat2x4<T,P> m(a);
if(io::row_major == fmt.order)
m = transpose(a);
if (fmt.formatted)
{
os << fmt.newline
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.delim_right;
} }
else
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x3<T,P> const& a)
{ {
os << m[0] << fmt.space << m[1]; return detail::print_matrix_on(os, a);
}
} }
return os; template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x4<T,P> const& a)
{
return detail::print_matrix_on(os, a);
} }
template <typename CTy, typename CTr, typename T, precision P> namespace detail
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x3<T,P> const& a) {
template <typename CTy, typename CTr, template <typename, precision> class M, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
print_matrix_pair_on(std::basic_ostream<CTy, CTr>& os, std::pair<M<T, P> const, M<T, P> const> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
if(cerberus) if(cerberus)
{ {
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os)); io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
tmat3x4<T,P> m(a); M<T,P> const& ml(a.first);
M<T,P> const& mr(a.second);
if(io::row_major == fmt.order) length_t const& cols(type<M, T, P>::cols);
m = transpose(a); length_t const& rows(type<M, T, P>::rows);
if(fmt.formatted) if(fmt.formatted)
{ {
os << fmt.newline os << fmt.newline << fmt.delim_left;
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.newline
<< fmt.space << m[2] << fmt.delim_right;
}
else
{
os << m[0] << fmt.space << m[1] << fmt.space << m[2];
}
}
return os; switch(fmt.order)
}
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x4<T,P> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); case io::column_major:
if(cerberus)
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); for(length_t i(0); i < rows; ++i)
tmat4x4<T,P> m(a); {
if(0 != i)
os << fmt.space;
if (io::row_major == fmt.order) os << row(ml, i) << ((rows-1 != i) ? fmt.space : fmt.delim_right) << fmt.space << ((0 != i) ? fmt.space : fmt.delim_left) << row(mr, i);
m = transpose(a);
if(fmt.formatted) if(rows-1 != i)
{ os << fmt.newline;
os << fmt.newline
<< fmt.delim_left << m[0] << fmt.newline
<< fmt.space << m[1] << fmt.newline
<< fmt.space << m[2] << fmt.newline
<< fmt.space << m[3] << fmt.delim_right;
} }
else
{
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3];
} }
} break;
case io::row_major:
return os;
}
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(
std::basic_ostream<CTy,CTr> & os,
std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const& a)
{ {
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os); for(length_t i(0); i < cols; ++i)
if(cerberus)
{ {
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os)); if(0 != i)
tmat4x4<T,P> ml(a.first); os << fmt.space;
tmat4x4<T,P> mr(a.second);
if(io::row_major == fmt.order) os << column(ml, i) << ((cols-1 != i) ? fmt.space : fmt.delim_right) << fmt.space << ((0 != i) ? fmt.space : fmt.delim_left) << column(mr, i);
{
ml = transpose(a.first);
mr = transpose(a.second);
}
if(fmt.formatted) if(cols-1 != i)
{ os << fmt.newline;
CTy const & l(fmt.delim_left); }
CTy const & r(fmt.delim_right); }
CTy const & s(fmt.space); break;
}
os << fmt.newline os << fmt.delim_right;
<< l << ml[0] << s << s << l << mr[0] << fmt.newline
<< s << ml[1] << s << s << s << mr[1] << fmt.newline
<< s << ml[2] << s << s << s << mr[2] << fmt.newline
<< s << ml[3] << r << s << s << mr[3] << r;
} }
else else
{ {
@ -645,12 +458,14 @@ namespace io
return os; return os;
} }
}//namespace detail
template <typename CTy, typename CTr, typename T, precision P> template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<( GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(
std::basic_ostream<CTy, CTr> & os, std::basic_ostream<CTy, CTr> & os,
std::pair<tmat4x4<T,P>, tmat4x4<T,P> > const& a) std::pair<tmat4x4<T, P> const,
tmat4x4<T, P> const> const& a)
{ {
return operator<<(os, static_cast<std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const&>(a)); return detail::print_matrix_pair_on(os, a);
} }
}//namespace glm }//namespace glm

@ -24,198 +24,255 @@
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE. /// THE SOFTWARE.
/// ///
/// @ref gtx_type_info /// @ref gtx_type_trait
/// @file glm/gtx/type_info.hpp /// @file glm/gtx/type_trait.hpp
/// @date 2016-03-12 / 2016-03-12 /// @date 2016-03-12 / 2016-03-12
/// @author Christophe Riccio /// @author Christophe Riccio
/// ///
/// @see core (dependence) /// @see core (dependence)
/// ///
/// @defgroup gtx_type_info GLM_GTX_type_info /// @defgroup gtx_type_trait GLM_GTX_type_trait
/// @ingroup gtx /// @ingroup gtx
/// ///
/// @brief Defines aligned types. /// @brief Defines traits for each type.
/// ///
/// <glm/gtx/type_aligned.hpp> need to be included to use these functionalities. /// <glm/gtx/type_trait.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#pragma once #pragma once
// Dependency: // Dependency:
#include "../detail/precision.hpp" #include "../detail/type_vec2.hpp"
#include "../detail/setup.hpp" #include "../detail/type_vec3.hpp"
#include "../detail/type_vec4.hpp"
#include "../detail/type_mat2x2.hpp"
#include "../detail/type_mat2x3.hpp"
#include "../detail/type_mat2x4.hpp"
#include "../detail/type_mat3x2.hpp"
#include "../detail/type_mat3x3.hpp"
#include "../detail/type_mat3x4.hpp"
#include "../detail/type_mat4x2.hpp"
#include "../detail/type_mat4x3.hpp"
#include "../detail/type_mat4x4.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/dual_quaternion.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_type_info extension included") # pragma message("GLM: GLM_GTX_type_trait extension included")
#endif #endif
namespace glm namespace glm
{ {
/// @addtogroup gtx_type_info /// @addtogroup gtx_type_trait
/// @{ /// @{
template <typename T, precision P> struct tvec1; template <template <typename, precision> class genType, typename T, precision P>
template <typename T, precision P> struct tvec2;
template <typename T, precision P> struct tvec3;
template <typename T, precision P> struct tvec4;
template <typename T, precision P> struct tmat2x2;
template <typename T, precision P> struct tmat2x3;
template <typename T, precision P> struct tmat2x4;
template <typename T, precision P> struct tmat3x2;
template <typename T, precision P> struct tmat3x3;
template <typename T, precision P> struct tmat3x4;
template <typename T, precision P> struct tmat4x2;
template <typename T, precision P> struct tmat4x3;
template <typename T, precision P> struct tmat4x4;
template <typename T, precision P> struct tquat;
template <typename T, precision P> struct tdualquat;
template <template <typename, precision> class genType>
struct type struct type
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = false; static bool const is_mat = false;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 0; static length_t const components = 0;
static length_t const cols = 0;
static length_t const rows = 0;
}; };
template <> template <typename T, precision P>
struct type<tvec1> struct type<tvec1, T, P>
{ {
static bool const is_vec = true; static bool const is_vec = true;
static bool const is_mat = false; static bool const is_mat = false;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 1; enum
{
components = 1
};
}; };
template <> template <typename T, precision P>
struct type<tvec2> struct type<tvec2, T, P>
{ {
static bool const is_vec = true; static bool const is_vec = true;
static bool const is_mat = false; static bool const is_mat = false;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 2; enum
{
components = 2
};
}; };
template <> template <typename T, precision P>
struct type<tvec3> struct type<tvec3, T, P>
{ {
static bool const is_vec = true; static bool const is_vec = true;
static bool const is_mat = false; static bool const is_mat = false;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 3; enum
{
components = 3
};
}; };
template <> template <typename T, precision P>
struct type<tvec4> struct type<tvec4, T, P>
{ {
static bool const is_vec = true; static bool const is_vec = true;
static bool const is_mat = false; static bool const is_mat = false;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 4; enum
{
components = 4
};
}; };
template <> template <typename T, precision P>
struct type<tmat2x2> struct type<tmat2x2, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 2; enum
{
components = 2,
cols = 2,
rows = 2
};
}; };
template <> template <typename T, precision P>
struct type<tmat2x3> struct type<tmat2x3, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 2; enum
{
components = 2,
cols = 2,
rows = 3
};
}; };
template <> template <typename T, precision P>
struct type<tmat2x4> struct type<tmat2x4, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 2; enum
{
components = 2,
cols = 2,
rows = 4
};
}; };
template <> template <typename T, precision P>
struct type<tmat3x2> struct type<tmat3x2, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 3; enum
static GLM_RELAXED_CONSTEXPR length_t cols = 3; {
static GLM_RELAXED_CONSTEXPR length_t rows = 2; components = 3,
cols = 3,
rows = 2
};
}; };
template <> template <typename T, precision P>
struct type<tmat3x3> struct type<tmat3x3, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 3; enum
{
components = 3,
cols = 3,
rows = 3
};
}; };
template <> template <typename T, precision P>
struct type<tmat3x4> struct type<tmat3x4, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 3; enum
{
components = 3,
cols = 3,
rows = 4
};
}; };
template <> template <typename T, precision P>
struct type<tmat4x2> struct type<tmat4x2, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 4; enum
{
components = 4,
cols = 4,
rows = 2
};
}; };
template <> template <typename T, precision P>
struct type<tmat4x3> struct type<tmat4x3, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 4; enum
{
components = 4,
cols = 4,
rows = 3
};
}; };
template <> template <typename T, precision P>
struct type<tmat4x4> struct type<tmat4x4, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = true; static bool const is_mat = true;
static bool const is_quat = false; static bool const is_quat = false;
static GLM_RELAXED_CONSTEXPR length_t components = 4; enum
{
components = 4,
cols = 4,
rows = 4
};
}; };
template <> template <typename T, precision P>
struct type<tquat> struct type<tquat, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = false; static bool const is_mat = false;
static bool const is_quat = true; static bool const is_quat = true;
static GLM_RELAXED_CONSTEXPR length_t components = 4; enum
{
components = 4
};
}; };
template <> template <typename T, precision P>
struct type<tdualquat> struct type<tdualquat, T, P>
{ {
static bool const is_vec = false; static bool const is_vec = false;
static bool const is_mat = false; static bool const is_mat = false;
static bool const is_quat = true; static bool const is_quat = true;
static GLM_RELAXED_CONSTEXPR length_t components = 8; enum
{
components = 8
};
}; };
/// @} /// @}

@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net) /// OpenGL Mathematics (glm.g-truc.net)
/// ///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Copyright (c) 2005 - 2016 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy /// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal /// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights /// in the Software without restriction, including without limitation the rights
@ -25,8 +25,8 @@
/// THE SOFTWARE. /// THE SOFTWARE.
/// ///
/// @file test/gtx/gtx_io.cpp /// @file test/gtx/gtx_io.cpp
/// @date 2013-11-22 / 2014-11-25 /// @date 2013-11-22 / 2016-03-14
/// @author Christophe Riccio /// @author Jan P Springer (regnirpsj@gmail.com)
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp> #include <glm/gtc/type_precision.hpp>
@ -128,7 +128,7 @@ int test_io_vec(OS& os)
} }
template <typename T, glm::precision P, typename OS> template <typename T, glm::precision P, typename OS>
int test_io_mat(OS& os) int test_io_mat(OS& os, glm::io::order_type otype)
{ {
os << '\n' << typeid(OS).name() << '\n'; os << '\n' << typeid(OS).name() << '\n';
@ -145,21 +145,10 @@ int test_io_mat(OS& os)
glm::tvec4<T,P> const v4_3(28, 29, 30, 31); glm::tvec4<T,P> const v4_3(28, 29, 30, 31);
glm::tvec4<T,P> const v4_4(32, 33, 34, 35); glm::tvec4<T,P> const v4_4(32, 33, 34, 35);
#if 0
os << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2<T,P>(v2_1, v2_2) << '\n'
<< "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3<T,P>(v3_1, v3_2) << '\n'
<< "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4<T,P>(v4_1, v4_2) << '\n'
<< "mat3x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x2<T,P>(v2_1, v2_2, v2_3) << '\n'
<< "mat3x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x3<T,P>(v3_1, v3_2, v3_3) << '\n'
<< "mat3x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x4<T,P>(v4_1, v4_2, v4_3) << '\n'
<< "mat4x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x2<T,P>(v2_1, v2_2, v2_3, v2_4) << '\n'
<< "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x3<T,P>(v3_1, v3_2, v3_3, v3_4) << '\n'
<< "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4<T,P>(v4_1, v4_2, v4_3, v4_4) << '\n';
#endif
glm::io::basic_format_saver<typename OS::char_type> const iofs(os); glm::io::basic_format_saver<typename OS::char_type> const iofs(os);
os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2) os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2)
<< glm::io::order(otype)
<< "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2<T,P>(v2_1, v2_2) << '\n' << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2<T,P>(v2_1, v2_2) << '\n'
<< "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3<T,P>(v3_1, v3_2) << '\n' << "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3<T,P>(v3_1, v3_2) << '\n'
<< "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4<T,P>(v4_1, v4_2) << '\n' << "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4<T,P>(v4_1, v4_2) << '\n'
@ -171,7 +160,7 @@ int test_io_mat(OS& os)
<< "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4<T,P>(v4_1, v4_2, v4_3, v4_4) << '\n'; << "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4<T,P>(v4_1, v4_2, v4_3, v4_4) << '\n';
os << glm::io::unformatted os << glm::io::unformatted
<< glm::io::order(glm::io::column_major) << glm::io::order(otype)
<< "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2<T,P>(v2_1, v2_2) << '\n' << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2<T,P>(v2_1, v2_2) << '\n'
<< "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3<T,P>(v3_1, v3_2) << '\n' << "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3<T,P>(v3_1, v3_2) << '\n'
<< "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4<T,P>(v4_1, v4_2) << '\n' << "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4<T,P>(v4_1, v4_2) << '\n'
@ -203,8 +192,10 @@ int main()
Error += test_io_vec<glm::uint, glm::lowp>(std::cout); Error += test_io_vec<glm::uint, glm::lowp>(std::cout);
Error += test_io_vec<glm::uint, glm::lowp>(std::wcout); Error += test_io_vec<glm::uint, glm::lowp>(std::wcout);
Error += test_io_mat<float, glm::highp>(std::cout); Error += test_io_mat<float, glm::highp>(std::cout, glm::io::column_major);
Error += test_io_mat<float, glm::lowp>(std::wcout); Error += test_io_mat<float, glm::lowp>(std::wcout, glm::io::column_major);
Error += test_io_mat<float, glm::highp>(std::cout, glm::io::row_major);
Error += test_io_mat<float, glm::lowp>(std::wcout, glm::io::row_major);
return Error; return Error;
} }

@ -1,78 +1,11 @@
#include <glm/vec4.hpp> #include <glm/vec4.hpp>
#include <glm/gtx/type_trait.hpp> #include <glm/gtx/type_trait.hpp>
template <typename genType>
struct type_gni
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
};
/*
template <template <class, glm::precision> class vecType, typename T, glm::precision P>
struct type_gni<vecType, T, P>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
};
*/
/*
namespace detail
{
template <template <typename, glm::precision> class vec_type>
struct compute_vec_type
{
static bool const is_vec = false;
static GLM_RELAXED_CONSTEXPR glm::length_t components = 0;
};
template <>
struct compute_vec_type<glm::tvec1>
{
static bool const is_vec = false;
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 1;
};
template <>
struct compute_vec_type<glm::tvec2>
{
static bool const is_vec = false;
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 2;
};
template <>
struct compute_vec_type<glm::tvec3>
{
static bool const is_vec = false;
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 3;
};
template <>
struct compute_vec_type<glm::tvec4>
{
static bool const is_vec = false;
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 4;
};
}//namespace detail
template <class gen_type>
struct vec_type
{
static bool const is_vec = detail::compute_vec_type<typename gen_type::vec_type>::is_vec;
//static GLM_RELAXED_CONSTEXPR glm::length_t const components = detail::compute_vec_type<typename gen_type::vec_type>::components;
};
*/
int main() int main()
{ {
int Error = 0; int Error = 0;
//typedef vec_type;
//bool const is_vec = detail::compute_vec_type<>::is_vec;
//Error += vec_type<glm::vec4>::is_vec ? 0 : 1;
//Error += vec_type<glm::vec4>::components == 4 ? 0 : 1;
return Error; return Error;
} }

Loading…
Cancel
Save