Ignore:
Timestamp:
Sep 8, 2011, 10:53:45 PM (11 years ago)
Author:
sam
Message:

core: add std::ostream operators for vector and matrix classes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/matrix.cpp

    r758 r929  
    8181}
    8282
     83template<> std::ostream &operator<<(std::ostream &stream, ivec2 const &v)
     84{
     85    return stream << "(" << v.x << ", " << v.y << ")";
     86}
     87
     88template<> std::ostream &operator<<(std::ostream &stream, ivec3 const &v)
     89{
     90    return stream << "(" << v.x << ", " << v.y << ", " << v.z << ")";
     91}
     92
     93template<> std::ostream &operator<<(std::ostream &stream, ivec4 const &v)
     94{
     95    return stream << "(" << v.x << ", " << v.y << ", "
     96                         << v.z << ", " << v.w << ")";
     97}
     98
     99template<> std::ostream &operator<<(std::ostream &stream, vec2 const &v)
     100{
     101    return stream << "(" << v.x << ", " << v.y << ")";
     102}
     103
     104template<> std::ostream &operator<<(std::ostream &stream, vec3 const &v)
     105{
     106    return stream << "(" << v.x << ", " << v.y << ", " << v.z << ")";
     107}
     108
     109template<> std::ostream &operator<<(std::ostream &stream, vec4 const &v)
     110{
     111    return stream << "(" << v.x << ", " << v.y << ", "
     112                         << v.z << ", " << v.w << ")";
     113}
     114
     115template<> std::ostream &operator<<(std::ostream &stream, mat4 const &m)
     116{
     117    stream << "((" << m[0][0] << ", " << m[1][0]
     118            << ", " << m[2][0] << ", " << m[3][0] << "), ";
     119    stream << "(" << m[0][1] << ", " << m[1][1]
     120           << ", " << m[2][1] << ", " << m[3][1] << "), ";
     121    stream << "(" << m[0][2] << ", " << m[1][2]
     122           << ", " << m[2][2] << ", " << m[3][2] << "), ";
     123    stream << "(" << m[0][3] << ", " << m[1][3]
     124           << ", " << m[2][3] << ", " << m[3][3] << "))";
     125    return stream;
     126}
     127
    83128template<> mat4 mat4::ortho(float left, float right, float bottom,
    84129                            float top, float near, float far)
Note: See TracChangeset for help on using the changeset viewer.