You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.2 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __OPEN_GL_WIDGET_HEADER__
  2. #define __OPEN_GL_WIDGET_HEADER__
  3. #include "../guiClass.h"
  4. #include <QtWidgets/QOpenGLWidget>
  5. #include <QtGui/QOpenGLFunctions>
  6. #include <QtGui/QOpenGLBuffer>
  7. #include <QtGui/QVector3D>
  8. #include <QtGui/QMatrix4x4>
  9. #include <QtCore/QTime>
  10. #include <QtCore/QVector>
  11. #include <QtWidgets/QPushButton>
  12. //class Bubble;
  13. class MainWindow;
  14. //QT_FORWARD_DECLARE_CLASS(QOpenGLTexture)
  15. //QT_FORWARD_DECLARE_CLASS(QOpenGLShader)
  16. //QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
  17. class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
  18. {
  19. //Q_OBJECT
  20. public:
  21. GLWidget(MainWindow *mw, bool button, const QColor &background);
  22. ~GLWidget();
  23. public slots:
  24. void setScaling(int scale);
  25. void setLogo();
  26. void setTexture();
  27. void setShowBubbles(bool);
  28. void setTransparent(bool transparent);
  29. private slots:
  30. void handleButtonPress();
  31. protected:
  32. void resizeGL(int w, int h) Q_DECL_OVERRIDE;
  33. void paintGL() Q_DECL_OVERRIDE;
  34. void initializeGL() Q_DECL_OVERRIDE;
  35. private:
  36. void paintTexturedCube();
  37. void paintQtLogo();
  38. void createGeometry();
  39. //void createBubbles(int number);
  40. void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
  41. void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
  42. MainWindow *m_mainWindow;
  43. qreal m_fAngle;
  44. qreal m_fScale;
  45. //bool m_showBubbles;
  46. QVector<QVector3D> m_vertices;
  47. QVector<QVector3D> m_normals;
  48. bool m_qtLogo;
  49. //QList<Bubble *> m_bubbles;
  50. int m_frames;
  51. QTime m_time;
  52. QOpenGLShader *m_vshader1;
  53. QOpenGLShader *m_fshader1;
  54. QOpenGLShader *m_vshader2;
  55. QOpenGLShader *m_fshader2;
  56. QOpenGLShaderProgram *m_program1;
  57. QOpenGLShaderProgram *m_program2;
  58. QOpenGLTexture *m_texture;
  59. QOpenGLBuffer m_vbo1;
  60. QOpenGLBuffer m_vbo2;
  61. int m_vertexAttr1;
  62. int m_normalAttr1;
  63. int m_matrixUniform1;
  64. int m_vertexAttr2;
  65. int m_normalAttr2;
  66. int m_texCoordAttr2;
  67. int m_matrixUniform2;
  68. int m_textureUniform2;
  69. bool m_transparent;
  70. QPushButton *m_btn;
  71. bool m_hasButton;
  72. QColor m_background;
  73. };
  74. #endif