]> git.sesse.net Git - nageru/blob - glwidget.h
Write 1.4.0 changelog.
[nageru] / glwidget.h
1 #ifndef GLWIDGET_H
2 #define GLWIDGET_H
3
4 #include <epoxy/gl.h>
5 #include <QGL>
6 #include <QString>
7 #include <string>
8 #include <vector>
9
10 #include "mixer.h"
11
12 class QMouseEvent;
13 class QObject;
14 class QPoint;
15 class QWidget;
16
17 namespace movit {
18
19 class ResourcePool;
20
21 }  // namespace movit
22
23 // Note: We use the older QGLWidget instead of QOpenGLWidget as it is
24 // much faster (does not go through a separate offscreen rendering step).
25 //
26 // TODO: Consider if QOpenGLWindow could do what we want.
27 class GLWidget : public QGLWidget
28 {
29         Q_OBJECT
30
31 public:
32         GLWidget(QWidget *parent = 0);
33
34         void set_output(Mixer::Output output)
35         {
36                 this->output = output;
37         }
38
39         void clean_context();
40
41 protected:
42         void initializeGL() override;
43         void resizeGL(int width, int height) override;
44         void paintGL() override;
45         void mousePressEvent(QMouseEvent *event) override;
46
47 signals:
48         void clicked();
49         void transition_names_updated(std::vector<std::string> transition_names);
50         void name_updated(Mixer::Output output, const std::string &name);
51         void color_updated(Mixer::Output output, const std::string &color);
52
53 private slots:
54         void show_context_menu(unsigned signal_num, const QPoint &pos);
55
56 private:
57         Mixer::Output output;
58         GLuint vao, program_num;
59         GLuint position_vbo, texcoord_vbo;
60         movit::ResourcePool *resource_pool = nullptr;
61 };
62
63 #endif