|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
// OpenGL Mathematics Copyright (c) 2006 G-Truc Creation (www.g-truc.net) |
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
|
// Created : 2008-04-27 |
|
|
|
|
// Updated : 2008-05-24 |
|
|
|
|
// Updated : 2014-05-10 |
|
|
|
|
// Licence : This source is under MIT License |
|
|
|
|
// File : glm/gtx/string_cast.hpp |
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
@ -35,410 +35,372 @@ namespace detail |
|
|
|
|
|
|
|
|
|
static const char* True = "true"; |
|
|
|
|
static const char* False = "false"; |
|
|
|
|
}//namespace detail |
|
|
|
|
|
|
|
|
|
//////////////////////////////// |
|
|
|
|
// Scalars |
|
|
|
|
template <typename T> |
|
|
|
|
struct prefix{}; |
|
|
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string(float x) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<float> |
|
|
|
|
{ |
|
|
|
|
return detail::format("float(%f)", x); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string(double x) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<double> |
|
|
|
|
{ |
|
|
|
|
return detail::format("double(%f)", x); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "d";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string(int x) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<bool> |
|
|
|
|
{ |
|
|
|
|
return detail::format("int(%d)", x); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "b";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string(unsigned int x) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<uint8_t> |
|
|
|
|
{ |
|
|
|
|
return detail::format("uint(%d)", x); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//////////////////////////////// |
|
|
|
|
// Bool vectors |
|
|
|
|
static char const * value() {return "u8";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec2<bool, P> const & v |
|
|
|
|
) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<int8_t> |
|
|
|
|
{ |
|
|
|
|
return detail::format("bvec2(%s, %s)", |
|
|
|
|
v.x ? detail::True : detail::False, |
|
|
|
|
v.y ? detail::True : detail::False); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "i8";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec3<bool, P> const & v |
|
|
|
|
) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<uint16_t> |
|
|
|
|
{ |
|
|
|
|
return detail::format("bvec3(%s, %s, %s)", |
|
|
|
|
v.x ? detail::True : detail::False, |
|
|
|
|
v.y ? detail::True : detail::False, |
|
|
|
|
v.z ? detail::True : detail::False); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "u16";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec4<bool, P> const & v |
|
|
|
|
) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<int16_t> |
|
|
|
|
{ |
|
|
|
|
return detail::format("bvec4(%s, %s, %s, %s)", |
|
|
|
|
v.x ? detail::True : detail::False, |
|
|
|
|
v.y ? detail::True : detail::False, |
|
|
|
|
v.z ? detail::True : detail::False, |
|
|
|
|
v.w ? detail::True : detail::False); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "i16";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//////////////////////////////// |
|
|
|
|
// Float vectors |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec2<float, P> const & v |
|
|
|
|
) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<uint32_t> |
|
|
|
|
{ |
|
|
|
|
return detail::format("fvec2(%f, %f)", v.x, v.y); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "u";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec3<float, P> const & v |
|
|
|
|
) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<int32_t> |
|
|
|
|
{ |
|
|
|
|
return detail::format("fvec3(%f, %f, %f)", v.x, v.y, v.z); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "i";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec4<float, P> const & v |
|
|
|
|
) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<uint64_t> |
|
|
|
|
{ |
|
|
|
|
return detail::format("fvec4(%f, %f, %f, %f)", v.x, v.y, v.z, v.w); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "u64";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//////////////////////////////// |
|
|
|
|
// Double vectors |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec2<double, P> const & v |
|
|
|
|
) |
|
|
|
|
template <> |
|
|
|
|
struct prefix<int64_t> |
|
|
|
|
{ |
|
|
|
|
return detail::format("dvec2(%f, %f)", v.x, v.y); |
|
|
|
|
} |
|
|
|
|
static char const * value() {return "i64";}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec3<double, P> const & v |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dvec3(%f, %f, %f)", v.x, v.y, v.z); |
|
|
|
|
} |
|
|
|
|
template <template <typename, precision> class matType, typename T, precision P> |
|
|
|
|
struct compute_to_string |
|
|
|
|
{}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec4<double, P> const & v |
|
|
|
|
) |
|
|
|
|
struct compute_to_string<tvec1, bool, P> |
|
|
|
|
{ |
|
|
|
|
return detail::format("dvec4(%f, %f, %f, %f)", v.x, v.y, v.z, v.w); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//////////////////////////////// |
|
|
|
|
// Int vectors |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tvec1<bool, P> const & x) |
|
|
|
|
{ |
|
|
|
|
return detail::format("bvec1(%s)", |
|
|
|
|
x[0] ? detail::True : detail::False); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec2<int, P> const & v |
|
|
|
|
) |
|
|
|
|
struct compute_to_string<tvec2, bool, P> |
|
|
|
|
{ |
|
|
|
|
return detail::format("ivec2(%d, %d)", v.x, v.y); |
|
|
|
|
} |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tvec2<bool, P> const & x) |
|
|
|
|
{ |
|
|
|
|
return detail::format("bvec2(%s, %s)", |
|
|
|
|
x[0] ? detail::True : detail::False, |
|
|
|
|
x[1] ? detail::True : detail::False); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec3<int, P> const & v |
|
|
|
|
) |
|
|
|
|
struct compute_to_string<tvec3, bool, P> |
|
|
|
|
{ |
|
|
|
|
return detail::format("ivec3(%d, %d, %d)", v.x, v.y, v.z); |
|
|
|
|
} |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tvec3<bool, P> const & x) |
|
|
|
|
{ |
|
|
|
|
return detail::format("bvec3(%s, %s, %s)", |
|
|
|
|
x[0] ? detail::True : detail::False, |
|
|
|
|
x[1] ? detail::True : detail::False, |
|
|
|
|
x[2] ? detail::True : detail::False); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec4<int, P> const & v |
|
|
|
|
) |
|
|
|
|
struct compute_to_string<tvec4, bool, P> |
|
|
|
|
{ |
|
|
|
|
return detail::format("ivec4(%d, %d, %d, %d)", v.x, v.y, v.z, v.w); |
|
|
|
|
} |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tvec4<bool, P> const & x) |
|
|
|
|
{ |
|
|
|
|
return detail::format("bvec4(%s, %s, %s, %s)", |
|
|
|
|
x[0] ? detail::True : detail::False, |
|
|
|
|
x[1] ? detail::True : detail::False, |
|
|
|
|
x[2] ? detail::True : detail::False, |
|
|
|
|
x[3] ? detail::True : detail::False); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//////////////////////////////// |
|
|
|
|
// Unsigned int vectors |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec2<unsigned int, P> const & v |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("uvec2(%d, %d)", v.x, v.y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec3<unsigned int, P> const & v |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("uvec3(%d, %d, %d)", v.x, v.y, v.z); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tvec4<unsigned int, P> const & v |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("uvec4(%d, %d, %d, %d)", v.x, v.y, v.z, v.w); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//////////////////////////////// |
|
|
|
|
// Float matrices |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat2x2<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat2x2((%f, %f), (%f, %f))", |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat2x3<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat2x3((%f, %f, %f), (%f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat2x4<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat2x4((%f, %f, %f, %f), (%f, %f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat3x2<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat3x2((%f, %f), (%f, %f), (%f, %f))", |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1], |
|
|
|
|
x[2][0], x[2][1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat3x3<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat3x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2], |
|
|
|
|
x[2][0], x[2][1], x[2][2]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat3x4<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat3x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3], |
|
|
|
|
x[2][0], x[2][1], x[2][2], x[2][3]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat4x2<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat4x2((%f, %f), (%f, %f), (%f, %f), (%f, %f))", |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1], |
|
|
|
|
x[2][0], x[2][1], |
|
|
|
|
x[3][0], x[3][1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat4x3<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat4x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2], |
|
|
|
|
x[2][0], x[2][1], x[2][2], |
|
|
|
|
x[3][0], x[3][1], x[3][2]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat4x4<float, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("mat4x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3], |
|
|
|
|
x[2][0], x[2][1], x[2][2], x[2][3], |
|
|
|
|
x[3][0], x[3][1], x[3][2], x[3][3]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//////////////////////////////// |
|
|
|
|
// Double matrices |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat2x2<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat2x2((%f, %f), (%f, %f))", |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat2x3<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat2x3((%f, %f, %f), (%f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat2x4<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat2x4((%f, %f, %f, %f), (%f, %f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat3x2<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat3x2((%f, %f), (%f, %f), (%f, %f))", |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1], |
|
|
|
|
x[2][0], x[2][1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat3x3<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat3x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2], |
|
|
|
|
x[2][0], x[2][1], x[2][2]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat3x4<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat3x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3], |
|
|
|
|
x[2][0], x[2][1], x[2][2], x[2][3]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat4x2<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat4x2((%f, %f), (%f, %f), (%f, %f), (%f, %f))", |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1], |
|
|
|
|
x[2][0], x[2][1], |
|
|
|
|
x[3][0], x[3][1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat4x3<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat4x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2], |
|
|
|
|
x[2][0], x[2][1], x[2][2], |
|
|
|
|
x[3][0], x[3][1], x[3][2]); |
|
|
|
|
} |
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tvec1, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tvec1<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%svec1(%s)", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), x[0]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tvec2, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tvec2<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%svec2(%s, %s)", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), x[0], x[1]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tvec3, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tvec3<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%svec3(%s, %s, %s)", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), x[0], x[1], x[2]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tvec4, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tvec4<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%svec4(%s, %s, %s, %s)", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), x[0], x[1], x[2], x[3]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat2x2, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat2x2<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat2x2((%s, %s), (%s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat2x3, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat2x3<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat2x3((%s, %s, %s), (%s, %s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat2x4, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat2x4<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat2x4((%s, %s, %s, %s), (%s, %s, %s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat3x2, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat3x2<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat3x2((%s, %s), (%s, %s), (%s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1], |
|
|
|
|
x[2][0], x[2][1]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat3x3, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat3x3<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat3x3((%s, %s, %s), (%s, %s, %s), (%s, %s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2], |
|
|
|
|
x[2][0], x[2][1], x[2][2]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat3x4, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat3x4<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat3x4((%s, %s, %s, %s), (%s, %s, %s, %s), (%s, %s, %s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3], |
|
|
|
|
x[2][0], x[2][1], x[2][2], x[2][3]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat4x2, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat4x2<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat4x2((%s, %s), (%s, %s), (%s, %s), (%s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], |
|
|
|
|
x[1][0], x[1][1], |
|
|
|
|
x[2][0], x[2][1], |
|
|
|
|
x[3][0], x[3][1]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat4x3, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat4x3<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat4x3((%s, %s, %s), (%s, %s, %s), (%s, %s, %s), (%s, %s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], x[0][2], |
|
|
|
|
x[1][0], x[1][1], x[1][2], |
|
|
|
|
x[2][0], x[2][1], x[2][2], |
|
|
|
|
x[3][0], x[3][1], x[3][2]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
struct compute_to_string<tmat4x4, T, P> |
|
|
|
|
{ |
|
|
|
|
GLM_FUNC_QUALIFIER static std::string call(tmat4x4<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
char const * PrefixStr = prefix<T>::value(); |
|
|
|
|
char const * LiteralStr = std::numeric_limits<T>::is_iec559 ? "%f" : "%d"; |
|
|
|
|
std::string FormatStr(detail::format("%smat4x4((%s, %s, %s, %s), (%s, %s, %s, %s), (%s, %s, %s, %s), (%s, %s, %s, %s))", |
|
|
|
|
PrefixStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr, |
|
|
|
|
LiteralStr, LiteralStr, LiteralStr, LiteralStr)); |
|
|
|
|
|
|
|
|
|
return detail::format(FormatStr.c_str(), |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3], |
|
|
|
|
x[2][0], x[2][1], x[2][2], x[2][3], |
|
|
|
|
x[3][0], x[3][1], x[3][2], x[3][3]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}//namespace detail |
|
|
|
|
|
|
|
|
|
template <precision P> |
|
|
|
|
GLM_FUNC_QUALIFIER std::string to_string |
|
|
|
|
( |
|
|
|
|
tmat4x4<double, P> const & x |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
return detail::format("dmat4x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", |
|
|
|
|
x[0][0], x[0][1], x[0][2], x[0][3], |
|
|
|
|
x[1][0], x[1][1], x[1][2], x[1][3], |
|
|
|
|
x[2][0], x[2][1], x[2][2], x[2][3], |
|
|
|
|
x[3][0], x[3][1], x[3][2], x[3][3]); |
|
|
|
|
} |
|
|
|
|
template <template <typename, precision> class matType, typename T, precision P> |
|
|
|
|
GLM_FUNC_DECL std::string to_string(matType<T, P> const & x) |
|
|
|
|
{ |
|
|
|
|
return detail::compute_to_string<matType, T, P>::call(x); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}//namespace glm |
|
|
|
|