/*** Olive - Non-Linear Video Editor Copyright (C) 2019 Olive Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ***/ #ifndef VIEWERGLWIDGET_H #define VIEWERGLWIDGET_H #include #include "render/colorservice.h" #include "render/gl/shaderptr.h" /** * @brief The inner display/rendering widget of a Viewer class. * * Actual composition occurs elsewhere offscreen and * multithreaded, so its main purpose is receiving a finalized OpenGL texture and displaying it. * * The main entry point is SetTexture() which will receive an OpenGL texture ID, store it, and then call update() to * draw it on screen. The drawing function is in paintGL() (called during the update() process by Qt) and is fairly * simple OpenGL drawing code standardized around OpenGL ES 3.2 Core. * * If the texture has been modified and you're 100% sure this widget is using the same texture object, it's possible * to call update() directly to trigger a repaint, however this is not recommended. If you are not 100% sure it'll be * the same texture object, use SetTexture() since it will nearly always be faster to just set it than to check *and* * set it. */ class ViewerGLWidget : public QOpenGLWidget { Q_OBJECT public: /** * @brief ViewerGLWidget Constructor * * @param parent * * QWidget parent. */ ViewerGLWidget(QWidget* parent); public slots: /** * @brief Set the texture to draw and draw it * * Use this function to update the viewer. * * @param tex */ void SetTexture(GLuint tex); protected: /** * @brief Initialize function to set up the OpenGL context upon its construction * * Currently primarily used to regenerate the pipeline shader used for drawing. */ virtual void initializeGL() override; /** * @brief Paint function to display the texture (received in SetTexture()) on screen. * * Simple OpenGL drawing function for painting the texture on screen. Standardized around OpenGL ES 3.2 Core. */ virtual void paintGL() override; private: /** * @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL(). */ GLuint texture_; /** * @brief Internal shader object to use as the pipeline shader * * Retrieved every initializeGL() in order to stay up to date when new contexts are generated. */ ShaderPtr pipeline_; /** * @brief OCIO LUT texture used for conversions */ GLuint ocio_lut_; /** * @brief Color management service */ ColorServicePtr color_service_; private slots: void ContextCleanup(); }; #endif // VIEWERGLWIDGET_H