DocumentDemo Example

/****************************************************************************
**
** Qtitan Library by Developer Machines (Dock Windows and Bars component for Qt.C++)
**
** Copyright (c) 2009-2022 Developer Machines (https://www.devmachines.com)
**           ALL RIGHTS RESERVED
**
**  The entire contents of this file is protected by copyright law and
**  international treaties. Unauthorized reproduction, reverse-engineering
**  and distribution of all or any portion of the code contained in this
**  file is strictly prohibited and may result in severe civil and
**  criminal penalties and will be prosecuted to the maximum extent
**  possible under the law.
**
**  RESTRICTIONS
**
**  THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED
**  FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE
**  COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE
**  AVAILABLE TO OTHER INDIVIDUALS WITHOUT WRITTEN CONSENT
**  AND PERMISSION FROM DEVELOPER MACHINES
**
**  CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON
**  ADDITIONAL RESTRICTIONS.
**
****************************************************************************/

#ifndef GLWIDGET_H
#define GLWIDGET_H

#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLBuffer>
#include <QVector3D>
#include <QMatrix4x4>
#include <QTime>
#include <QVector>
#include <QPushButton>

class Bubble;
class MainWindow;

QT_FORWARD_DECLARE_CLASS(QOpenGLTexture)
QT_FORWARD_DECLARE_CLASS(QOpenGLShader)
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)

class MyGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
//    Q_OBJECT
public:
    MyGLWidget(MainWindow *mw, bool button, const QColor &background);
    ~MyGLWidget();

public slots:
    void setScaling(int scale);
    void setLogo();
    void setTexture();
    void setShowBubbles(bool);
    void setTransparent(bool transparent);

private slots:
    void handleButtonPress();

protected:
    void resizeGL(int w, int h) override;
    void paintGL() override;
    void initializeGL() override;

private:
    void paintTexturedCube();
    void paintQtLogo();
    void createGeometry();
    void createBubbles(int number);
    void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
    void extrude(qreal x1, qreal y1, qreal x2, qreal y2);

    MainWindow *m_mainWindow;
    qreal m_fAngle;
    qreal m_fScale;
    bool m_showBubbles;
    QVector<QVector3D> m_vertices;
    QVector<QVector3D> m_normals;
    bool m_qtLogo;
    QList<Bubble *> m_bubbles;
    int m_frames;
    QTime m_time;
    QOpenGLShader *m_vshader1;
    QOpenGLShader *m_fshader1;
    QOpenGLShader *m_vshader2;
    QOpenGLShader *m_fshader2;
    QOpenGLShaderProgram *m_program1;
    QOpenGLShaderProgram *m_program2;
    QOpenGLTexture *m_texture;
    QOpenGLBuffer m_vbo1;
    QOpenGLBuffer m_vbo2;
    int m_vertexAttr1;
    int m_normalAttr1;
    int m_matrixUniform1;
    int m_vertexAttr2;
    int m_normalAttr2;
    int m_texCoordAttr2;
    int m_matrixUniform2;
    int m_textureUniform2;
    bool m_transparent;
    QPushButton *m_btn;
    bool m_hasButton;
    QColor m_background;
};

#endif