]> git.sur5r.net Git - fstl/blob - src/canvas.h
Mostly complete from the Python original
[fstl] / src / canvas.h
1 #ifndef CANVAS_H
2 #define CANVAS_H
3
4 #include <QWidget>
5 #include <QtOpenGL/QGLWidget>
6 #include <QtOpenGL/QGLShaderProgram>
7 #include <QMatrix4x4>
8
9 class GLMesh;
10 class Mesh;
11
12 class Canvas : public QGLWidget
13 {
14     Q_OBJECT
15
16 public:
17     Canvas(const QGLFormat& format, QWidget* parent=0);
18
19     void initializeGL();
20     void paintGL();
21     ~Canvas();
22
23 public slots:
24     void load_mesh(Mesh* m);
25
26
27 protected:
28     void mousePressEvent(QMouseEvent* event);
29     void mouseReleaseEvent(QMouseEvent* event);
30     void mouseMoveEvent(QMouseEvent* event);
31
32
33 private:
34     void draw_mesh();
35
36     QMatrix4x4 transform_matrix() const;
37     QMatrix4x4 view_matrix() const;
38
39     QGLShaderProgram mesh_shader;
40     QGLShaderProgram quad_shader;
41
42     GLMesh* mesh;
43
44     QVector3D center;
45     float scale;
46     float tilt;
47     float yaw;
48
49     QPoint mouse_pos;
50 };
51
52 #endif // CANVAS_H