CuteLogger
Fast and simple logging solution for Qt based applications
openglvideowidget.h
1 /*
2  * Copyright (c) 2023 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef OPENGLVIDEOWIDGET_H
19 #define OPENGLVIDEOWIDGET_H
20 
21 #include "videowidget.h"
22 
23 #include <QOffscreenSurface>
24 #include <QOpenGLContext>
25 #include <QOpenGLFramebufferObject>
26 #include <QOpenGLFunctions>
27 #include <QOpenGLShaderProgram>
28 
29 class OpenGLVideoWidget : public Mlt::VideoWidget, protected QOpenGLFunctions
30 {
31  Q_OBJECT
32 
33 public:
34  explicit OpenGLVideoWidget(QObject *parent = nullptr);
35  virtual ~OpenGLVideoWidget();
36 
37 public slots:
38  virtual void initialize();
39  virtual void renderVideo();
40  virtual void onFrameDisplayed(const SharedFrame &frame);
41 
42 private:
43  void createShader();
44 
45  QOffscreenSurface m_offscreenSurface;
46  std::unique_ptr<QOpenGLShaderProgram> m_shader;
47  GLint m_projectionLocation;
48  GLint m_modelViewLocation;
49  GLint m_vertexLocation;
50  GLint m_texCoordLocation;
51  GLint m_colorspaceLocation;
52  GLint m_textureLocation[3];
53  QOpenGLContext *m_quickContext;
54  std::unique_ptr<QOpenGLContext> m_context;
55  GLuint m_renderTexture[3];
56  GLuint m_displayTexture[3];
57  bool m_isThreadedOpenGL;
58 };
59 
60 #endif // OPENGLVIDEOWIDGET_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:50