00001 #ifndef GUI_GL_MATRIX4_HPP 00002 #define GUI_GL_MATRIX4_HPP 00003 00004 #include <gui_vector2.hpp> 00005 #include <initializer_list> 00006 #include <iosfwd> 00007 00008 namespace gui { 00009 namespace gl 00010 { 00011 class matrix4 00012 { 00013 public : 00014 00015 typedef float T; 00016 00017 matrix4(); 00018 matrix4(std::initializer_list<T> mList); 00019 matrix4(T* mat); 00020 00021 inline T& operator () (size_t i, size_t j) 00022 { 00023 return data[j][i]; 00024 } 00025 00026 inline const T& operator () (size_t i, size_t j) const 00027 { 00028 return data[j][i]; 00029 } 00030 00031 inline T& operator () (size_t i) 00032 { 00033 return data[i/4][i%4]; 00034 } 00035 00036 inline const T& operator () (size_t i) const 00037 { 00038 return data[i/4][i%4]; 00039 } 00040 00041 void make_translation(const vector2f& dx); 00042 void make_scaling(const vector2f& scale); 00043 void make_rotation(float rot); 00044 void make_transformation(const vector2f& dx, const vector2f& scale, float rot); 00045 00046 void transpose(); 00047 void invert(); 00048 00049 static matrix4 translation(const vector2f& dx); 00050 static matrix4 scaling(const vector2f& scale); 00051 static matrix4 rotation(float rot); 00052 static matrix4 transformation(const vector2f& dx, const vector2f& scale, float rot); 00053 00054 static matrix4 transpose(const matrix4& m); 00055 static matrix4 invert(const matrix4& m); 00056 00057 matrix4 operator + (const matrix4& m); 00058 matrix4 operator - (const matrix4& m); 00059 matrix4 operator * (const matrix4& m); 00060 vector2f operator * (const vector2f& v); 00061 00062 T data[4][4]; 00063 00064 static const matrix4 IDENTITY; 00065 }; 00066 00067 std::ostream& operator << (std::ostream& o, const matrix4& m); 00068 } 00069 } 00070 00071 #endif