]> git.sesse.net Git - nageru/blob - glwidget.h
Make signal mapping changeable by right-clicking on the preview.
[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 resolution_updated(Mixer::Output output);
50
51 private slots:
52         void show_context_menu(int signal_num, const QPoint &pos);
53
54 private:
55         Mixer::Output output;
56         GLuint vao, program_num;
57         GLuint position_vbo, texcoord_vbo;
58         movit::ResourcePool *resource_pool = nullptr;
59 };
60
61 #endif