]> git.sur5r.net Git - fstl/blob - src/canvas.h
c094e5b228d1238129f593907fd151c53d1ae682
[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 class Backdrop;
12
13 class Canvas : public QGLWidget
14 {
15     Q_OBJECT
16
17 public:
18     Canvas(const QGLFormat& format, QWidget* parent=0);
19
20     void initializeGL();
21     void paintGL();
22     ~Canvas();
23
24 public slots:
25     void load_mesh(Mesh* m);
26
27
28 protected:
29     void mousePressEvent(QMouseEvent* event);
30     void mouseReleaseEvent(QMouseEvent* event);
31     void mouseMoveEvent(QMouseEvent* event);
32
33
34 private:
35     void draw_mesh();
36
37     QMatrix4x4 transform_matrix() const;
38     QMatrix4x4 view_matrix() const;
39
40     QGLShaderProgram mesh_shader;
41     QGLShaderProgram quad_shader;
42
43     GLMesh* mesh;
44     Backdrop* backdrop;
45
46     QVector3D center;
47     float scale;
48     float tilt;
49     float yaw;
50
51     QPoint mouse_pos;
52 };
53
54 #endif // CANVAS_H