]> git.sesse.net Git - nageru/blob - glwidget.h
Support audio-only FFmpeg inputs. Somewhat wonky, though.
[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         // NOTE: Will make the white balance flicker for a frame.
43         void grab_white_balance(unsigned channel, unsigned x, unsigned y);
44
45 protected:
46         void initializeGL() override;
47         void resizeGL(int width, int height) override;
48         void paintGL() override;
49         void mousePressEvent(QMouseEvent *event) override;
50
51 signals:
52         void clicked();
53         void transition_names_updated(std::vector<std::string> transition_names);
54         void name_updated(Mixer::Output output, const std::string &name);
55         void color_updated(Mixer::Output output, const std::string &color);
56
57 private slots:
58         void show_context_menu(const QPoint &pos);
59
60 private:
61         void show_live_context_menu(const QPoint &pos);
62         void show_preview_context_menu(unsigned signal_num, const QPoint &pos);
63
64         Mixer::Output output;
65         GLuint vao, program_num;
66         GLuint position_vbo, texcoord_vbo;
67         movit::ResourcePool *resource_pool = nullptr;
68         int current_width = 1, current_height = 1;
69         bool should_grab = false;
70         unsigned grab_x, grab_y;
71         Mixer::Output grab_output;  // Should nominally be the same as output.
72 };
73
74 #endif