CPP-TOOLBOX
Loading...
Searching...
No Matches
glm_printing.hpp
Go to the documentation of this file.
1#ifndef GLM_PRINTING_HPP
2#define GLM_PRINTING_HPP
3
4#include <iostream>
5
6#define GLM_ENABLE_EXPERIMENTAL
7
8#include <glm/glm.hpp>
9#include <glm/gtc/matrix_transform.hpp>
10#include <glm/gtc/quaternion.hpp>
11#include <glm/gtc/constants.hpp>
12#include <iomanip>
13#include <sstream>
14
15void print_translation_rotation_scale_of_matrix_transform(const glm::mat4 &transform);
16
17inline std::ostream &operator<<(std::ostream &os, const glm::vec2 &v) { return os << "(" << v.x << ", " << v.y << ")"; }
18
19// inline std::ostream &operator<<(std::ostream &os, const glm::vec3 &v) {
20// return os << "(" << v.x << ", " << v.y << ", " << v.z << ")";
21// }
22
23std::string vec3_to_string(const glm::vec3 &v, int precision = 1);
24std::string vec2_to_string(const glm::vec2 &v, int precision = 1);
25
26std::string mat4_to_string(const glm::mat4 &m, int precision = 1);
27
28namespace glm {
29inline std::ostream &operator<<(std::ostream &os, const glm::vec3 &v) {
30 return os << "(" << v.x << ", " << v.y << ", " << v.z << ")";
31}
32} // namespace glm
33
34inline std::ostream &operator<<(std::ostream &os, const glm::vec4 &v) {
35 return os << "(" << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ")";
36}
37
38inline std::ostream &operator<<(std::ostream &os, const glm::mat4 &m) {
39 os << "(\n";
40 for (int i = 0; i < 4; ++i) {
41 os << " ";
42 for (int j = 0; j < 4; ++j) {
43 os << m[j][i] << " "; // glm stores matrices in column-major order
44 }
45 os << "\n";
46 }
47 return os << ")";
48}
49
50#endif // GLM_PRINTING_HPP
std::ostream & operator<<(std::ostream &os, const glm::vec2 &v)
Definition glm_printing.hpp:17
std::string vec3_to_string(const glm::vec3 &v, int precision=1)
Definition glm_printing.cpp:38
void print_translation_rotation_scale_of_matrix_transform(const glm::mat4 &transform)
Definition glm_printing.cpp:3
std::string vec2_to_string(const glm::vec2 &v, int precision=1)
Definition glm_printing.cpp:31
std::string mat4_to_string(const glm::mat4 &m, int precision=1)
Definition glm_printing.cpp:45
@ j
Definition input_state.hpp:36
@ m
Definition input_state.hpp:39
@ i
Definition input_state.hpp:35
@ v
Definition input_state.hpp:48
Definition glm_printing.hpp:28
std::ostream & operator<<(std::ostream &os, const glm::vec3 &v)
Definition glm_printing.hpp:29