]> git.sesse.net Git - nageru/blob - glwidget.h
Fix an off-by-two that could lead to undefined samples in the buffer in panic situations.
[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 class ResourcePool;
18 }
19
20 // Note: We use the older QGLWidget instead of QOpenGLWidget as it is
21 // much faster (does not go through a separate offscreen rendering step).
22 //
23 // TODO: Consider if QOpenGLWindow could do what we want.
24 class GLWidget : public QGLWidget
25 {
26         Q_OBJECT
27
28 public:
29         GLWidget(QWidget *parent = 0);
30         ~GLWidget();
31
32         void set_output(Mixer::Output output)
33         {
34                 this->output = output;
35         }
36
37 protected:
38         void initializeGL() override;
39         void resizeGL(int width, int height) override;
40         void paintGL() override;
41         void mousePressEvent(QMouseEvent *event) override;
42
43 signals:
44         void clicked();
45         void transition_names_updated(std::vector<std::string> transition_names);
46
47 private:
48         Mixer::Output output;
49         movit::ResourcePool *resource_pool;
50         GLuint vao, program_num;
51         GLuint position_vbo, texcoord_vbo;
52 };
53
54 #endif