3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GL_MATRIX_H_
9 #define MSP_GL_MATRIX_H_
34 Matrix(const float *);
35 Matrix(const double *);
40 const double *data() const { return matrix; }
42 void multiply(const Matrix &);
43 void translate(double, double, double);
44 void rotate(double, double, double, double);
45 void rotate_deg(double, double, double, double);
47 void scale(double, double, double);
49 Matrix operator*(const Matrix &) const;
50 Matrix &operator*=(const Matrix &);
51 double operator[](unsigned) const;
53 static Matrix translation(double, double, double);
54 static Matrix rotation(double, double, double, double);
55 static Matrix rotation_deg(double, double, double, double);
56 static Matrix scaling(double);
57 static Matrix scaling(double, double, double);
59 static Matrix ortho(double, double, double, double, double, double);
60 static Matrix ortho_centered(double, double);
61 static Matrix ortho_bottomleft(double, double);
62 static Matrix ortho_topleft(double, double);
63 static Matrix frustum(double, double, double, double, double, double);
64 static Matrix frustum_centered(double, double, double, double);
65 static Matrix perspective(double, double, double, double);
77 Push(MatrixStack &s): stack(s) { stack.push(); }
78 ~Push() { stack.pop(); }
83 std::list<Matrix> matrices;
85 static GLenum current_mode;
87 MatrixStack(const MatrixStack &);
88 MatrixStack &operator=(const MatrixStack &);
94 void load(const Matrix &);
95 void multiply(const Matrix &);
102 MatrixStack &operator=(const Matrix &);
103 MatrixStack &operator*=(const Matrix &);
105 static MatrixStack &modelview();
106 static MatrixStack &projection();
110 /* The stuff below is deprecated and preserved (for now) only for compatibility
111 with existing applications */
115 MODELVIEW = GL_MODELVIEW,
116 PROJECTION = GL_PROJECTION,
120 void matrix_mode(MatrixMode);
121 void load_identity();
122 void load_matrix(const float *);
123 void load_matrix(const double *);
124 void mult_matrix(const float *);
125 void mult_matrix(const double *);
129 /// RAII object - pushes matrix when constructed and pops when destroyed
132 PushMatrix() { push_matrix(); }
133 ~PushMatrix() { pop_matrix(); }
136 void translate(float, float, float);
137 void rotate(float, float, float, float);
138 void scale(float, float, float);
139 void scale_uniform(float);