From 81078a6b49e7c16f7ca4a0861b038a28ea611836 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 2 Apr 2019 23:26:53 +0200 Subject: [PATCH] Add ostream operator<< for glm::vec{2,3,4} --- src/utilities/glmhelpers.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utilities/glmhelpers.hpp b/src/utilities/glmhelpers.hpp index 18f401a..db82a4d 100644 --- a/src/utilities/glmhelpers.hpp +++ b/src/utilities/glmhelpers.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include // prettifies some of the maths with vectors @@ -18,3 +19,8 @@ constexpr glm::vec4 operator*(double lhs, glm::vec4 rhs) { return rhs * lhs; } constexpr glm::vec4 operator/(double lhs, glm::vec4 rhs) { return rhs / lhs; } constexpr glm::vec2 flip(glm::vec2 a) { return {a.y, a.x}; } + + +inline std::ostream& operator<<(std::ostream& os, vec2 v) { return os << "vec2(" << v.x << ", " << v.y << ")"; } +inline std::ostream& operator<<(std::ostream& os, vec3 v) { return os << "vec3(" << v.x << ", " << v.y << ", " << v.z << ")"; } +inline std::ostream& operator<<(std::ostream& os, vec4 v) { return os << "vec4(" << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ")"; }