I am debugging an OpenGL program:
Is there some kind of toString() functionality for matrices and vectors (mat3, mat4, vec3 &c)?
I'm trying to avoid constructing nested for-loops with cout or printf.
But if that's the only way to do this, I"d love to hear advice on best practices. I'm pretty new to C++ and am interested to hear about it.
What would be really cool is output to a laTeX / ConTeXt logfile.
That leads to a more extended version of the question: is there some reflection functionality for these objects? I'd like to know if the particular matrix I'm interested in is specified column-major or row-major, what/where its parent class is, &c.
Overload the ofstream << operator for your matrix/vector class and then inside format it the way you want i.e. output << "(" << vector.x << " ", " << vector.y << etc. Then in your main program you can simply do std::cout << myVector << std::endl;
http://www.learncpp.com/cpp-tutorial/93-overloading-the-io-operators/
The link shows how it can be implemented