File indexing completed on 2024-05-05 04:53:39

0001 /*
0002     SPDX-FileCopyrightText: 2023 Meltytech, LLC
0003     SPDX-License-Identifier: GPL-3.0-or-later
0004 */
0005 
0006 #pragma once
0007 
0008 #include "videowidget.h"
0009 
0010 #include <QOffscreenSurface>
0011 #include <QOpenGLContext>
0012 #include <QOpenGLFramebufferObject>
0013 #include <QOpenGLFunctions>
0014 #include <QOpenGLShaderProgram>
0015 
0016 class OpenGLVideoWidget : public VideoWidget, protected QOpenGLFunctions
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     explicit OpenGLVideoWidget(int id, QObject *parent = nullptr);
0022     virtual ~OpenGLVideoWidget();
0023     const QStringList getGPUInfo() override;
0024 
0025 public Q_SLOTS:
0026     virtual void initialize() override;
0027     virtual void renderVideo() override;
0028     virtual void onFrameDisplayed(const SharedFrame &frame) override;
0029 
0030 private:
0031     void createShader();
0032 
0033     QOffscreenSurface m_offscreenSurface;
0034     std::unique_ptr<QOpenGLShaderProgram> m_shader;
0035     GLint m_projectionLocation;
0036     GLint m_modelViewLocation;
0037     GLint m_vertexLocation;
0038     GLint m_texCoordLocation;
0039     GLint m_colorspaceLocation;
0040     GLint m_textureLocation[3];
0041     QOpenGLContext *m_quickContext;
0042     std::unique_ptr<QOpenGLContext> m_context;
0043     QOpenGLFramebufferObject *m_fbo{nullptr};
0044     GLuint m_renderTexture[3];
0045     GLuint m_displayTexture[3];
0046     bool m_isThreadedOpenGL;
0047 };