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