]> git.sur5r.net Git - fstl/blob - src/canvas.h
Painting status string as text
[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 paintEvent(QPaintEvent* event);
22     ~Canvas();
23
24 public slots:
25     void set_status(const QString& s);
26     void load_mesh(Mesh* m);
27
28
29 protected:
30     void mousePressEvent(QMouseEvent* event);
31     void mouseReleaseEvent(QMouseEvent* event);
32     void mouseMoveEvent(QMouseEvent* event);
33
34
35 private:
36     void draw_mesh();
37
38     QMatrix4x4 transform_matrix() const;
39     QMatrix4x4 view_matrix() const;
40
41     QGLShaderProgram mesh_shader;
42     QGLShaderProgram quad_shader;
43
44     GLMesh* mesh;
45     Backdrop* backdrop;
46
47     QVector3D center;
48     float scale;
49     float tilt;
50     float yaw;
51
52     QPoint mouse_pos;
53     QString status;
54 };
55
56 #endif // CANVAS_H