]> git.sesse.net Git - nageru/blob - glwidget.h
Fix an issue where the mixer lagging too much behind CEF would cause us to display...
[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         ~GLWidget();
34
35         void set_output(Mixer::Output output)
36         {
37                 this->output = output;
38         }
39
40         void shutdown();
41
42 protected:
43         void initializeGL() override;
44         void resizeGL(int width, int height) override;
45         void paintGL() override;
46         void mousePressEvent(QMouseEvent *event) override;
47
48 signals:
49         void clicked();
50         void transition_names_updated(std::vector<std::string> transition_names);
51         void name_updated(Mixer::Output output, const std::string &name);
52         void color_updated(Mixer::Output output, const std::string &color);
53
54 private slots:
55         void show_context_menu(const QPoint &pos);
56
57 private:
58         void show_live_context_menu(const QPoint &pos);
59         void show_preview_context_menu(unsigned signal_num, const QPoint &pos);
60
61         Mixer::Output output;
62         GLuint vao, program_num;
63         GLuint position_vbo, texcoord_vbo;
64         movit::ResourcePool *resource_pool = nullptr;
65         int current_width = 1, current_height = 1;
66 };
67
68 #endif