| 1 |
// Copyright (C) 2017 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
| 3 |
|
| 4 |
#ifndef GLWIDGET_H |
| 5 |
#define GLWIDGET_H |
| 6 |
|
| 7 |
#include <QOpenGLWindow> |
| 8 |
#include <QOpenGLTexture> |
| 9 |
#include <QMatrix4x4> |
| 10 |
#include <QVector3D> |
| 11 |
#include <QKeyEvent> |
| 12 |
#include <QPropertyAnimation> |
| 13 |
#include <QSequentialAnimationGroup> |
| 14 |
#include <QRectF> |
| 15 |
|
| 16 |
QT_BEGIN_NAMESPACE |
| 17 |
|
| 18 |
class QOpenGLTexture; |
| 19 |
class QOpenGLShaderProgram; |
| 20 |
class QOpenGLBuffer; |
| 21 |
class QOpenGLVertexArrayObject; |
| 22 |
|
| 23 |
QT_END_NAMESPACE |
| 24 |
|
| 25 |
class GLWindow : public QOpenGLWindow |
| 26 |
{ |
| 27 |
Q_OBJECT |
| 28 |
Q_PROPERTY(float blurRadius READ blurRadius WRITE setBlurRadius) |
| 29 |
|
| 30 |
public: |
| 31 |
GLWindow(); |
| 32 |
~GLWindow(); |
| 33 |
|
| 34 |
void initializeGL() override; |
| 35 |
void resizeGL(int w, int h) override; |
| 36 |
void paintGL() override; |
| 37 |
|
| 38 |
float blurRadius() const { return m_blurRadius; } |
| 39 |
void setBlurRadius(float blurRadius); |
| 40 |
|
| 41 |
protected: |
| 42 |
void keyPressEvent(QKeyEvent *e) override; |
| 43 |
void setAnimating(bool animate); |
| 44 |
|
| 45 |
private: |
| 46 |
QPropertyAnimation *m_animationForward = nullptr; |
| 47 |
QPropertyAnimation *m_animationBackward = nullptr; |
| 48 |
QSequentialAnimationGroup *m_animationGroup; |
| 49 |
QOpenGLTexture *m_texImageInput = nullptr; |
| 50 |
QOpenGLTexture *m_texImageTmp = nullptr; |
| 51 |
QOpenGLTexture *m_texImageProcessed = nullptr; |
| 52 |
QOpenGLShaderProgram *m_shaderDisplay = nullptr; |
| 53 |
QOpenGLShaderProgram *m_shaderComputeV = nullptr; |
| 54 |
QOpenGLShaderProgram *m_shaderComputeH = nullptr; |
| 55 |
QMatrix4x4 m_proj; |
| 56 |
QSizeF m_quadSize; |
| 57 |
|
| 58 |
int m_blurRadius = 0; |
| 59 |
bool m_animate = true; |
| 60 |
QOpenGLVertexArrayObject *m_vao = nullptr; |
| 61 |
}; |
| 62 |
|
| 63 |
#endif |