stream operator for all variants of glm vec

This commit is contained in:
frank 2021-10-08 23:43:09 -04:00
parent f70ea1c215
commit a6bcc2a4d9
2 changed files with 18 additions and 14 deletions

View File

@ -647,18 +647,6 @@ int lineColor(SDL_Renderer* renderer, const Segment& segment, const Color& color
}
}
std::ostream& operator<<(std::ostream& out, const glm::vec2& vector)
{
out << "{" << vector.x << ", " << vector.y << "}";
return out;
}
std::ostream& operator<<(std::ostream& out, const glm::vec3& vector)
{
out << "{" << vector.x << ", " << vector.y << ", " << vector.z << "}";
return out;
}
std::ostream& operator<<(std::ostream& out, const SDL_Color& color)
{
out << "{" << static_cast<int>(color.r) << ", " << static_cast<int>(color.g) << ", " <<

View File

@ -202,8 +202,24 @@ std::ostream& operator<<(std::ostream& out, const std::vector<T>& members)
return out;
}
std::ostream& operator<<(std::ostream&, const glm::vec2&);
std::ostream& operator<<(std::ostream&, const glm::vec3&);
/* Stream a text representation of a glm::vec of any type or dimension */
template<int dimensions, typename Type>
std::ostream& operator<<(std::ostream& out, const glm::vec<dimensions, Type, glm::defaultp> vec)
{
out << "{" << vec.x << ", " << vec.y;
if constexpr (dimensions > 2)
{
out << ", " << vec.z;
if constexpr (dimensions > 3)
{
out << ", " << vec.w;
}
}
out << "}";
return out;
}
std::ostream& operator<<(std::ostream&, const SDL_Color&);
#endif