1 #ifndef MSP_GL_MATRIX_H_
2 #define MSP_GL_MATRIX_H_
28 Matrix(const float *);
29 Matrix(const double *);
34 const double *data() const { return matrix; }
36 void multiply(const Matrix &);
37 void translate(double, double, double);
38 void translate(const Vector3 &t) { translate(t.x, t.y, t.z); }
39 void rotate(double, double, double, double);
40 void rotate(double a, const Vector3 &x) { rotate(a, x.x, x.y, x.z); }
41 void rotate_deg(double, double, double, double);
42 void rotate_deg(double a, const Vector3 & x) { rotate_deg(a, x.x, x.y, x.z); }
44 void scale(double, double, double);
46 Matrix operator*(const Matrix &) const;
47 Matrix &operator*=(const Matrix &);
48 Vector4 operator*(const Vector4 &) const;
49 double operator[](unsigned) const;
51 static Matrix translation(double, double, double);
52 static Matrix translation(const Vector3 &t) { return translation(t.x, t.y, t.z); }
53 static Matrix rotation(double, double, double, double);
54 static Matrix rotation(double a, const Vector3 &x) { return rotation(a, x.x, x.y, x.z); }
55 static Matrix rotation_deg(double, double, double, double);
56 static Matrix rotation_deg(double a, const Vector3 &x) { return rotation_deg(a, x.x, x.y, x.z); }
57 static Matrix scaling(double);
58 static Matrix scaling(double, double, double);
60 static Matrix ortho(double, double, double, double, double, double);
61 static Matrix ortho_centered(double, double);
62 static Matrix ortho_bottomleft(double, double);
63 static Matrix ortho_topleft(double, double);
64 static Matrix frustum(double, double, double, double, double, double);
65 static Matrix frustum_centered(double, double, double, double);
66 static Matrix perspective(double, double, double, double);
78 Push(MatrixStack &s): stack(s) { stack.push(); }
79 ~Push() { stack.pop(); }
84 std::vector<Matrix> matrices;
86 static GLenum current_mode;
88 MatrixStack(const MatrixStack &);
89 MatrixStack &operator=(const MatrixStack &);
94 const Matrix &top() const;
95 void load(const Matrix &);
96 void multiply(const Matrix &);
100 virtual void update();
103 MatrixStack &operator=(const Matrix &);
104 MatrixStack &operator*=(const Matrix &);
106 static MatrixStack &modelview();
107 static MatrixStack &projection();
111 /* The stuff below is deprecated and preserved (for now) only for compatibility
112 with existing applications */
116 MODELVIEW = GL_MODELVIEW,
117 PROJECTION = GL_PROJECTION,
121 void matrix_mode(MatrixMode);
122 void load_identity();
123 void load_matrix(const float *);
124 void load_matrix(const double *);
125 void mult_matrix(const float *);
126 void mult_matrix(const double *);
130 /// RAII object - pushes matrix when constructed and pops when destroyed
133 PushMatrix() { push_matrix(); }
134 ~PushMatrix() { pop_matrix(); }
137 void translate(float, float, float);
138 void rotate(float, float, float, float);
139 void scale(float, float, float);
140 void scale_uniform(float);