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.

88 lines
2.4 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __OGL_CAMERA_WIDGET_HEADER__
  2. #define __OGL_CAMERA_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 OglCameraWidget : public QOpenGLWidget, protected QOpenGLFunctions {
  18. //Q_OBJECT
  19. public:
  20. OglCameraWidget( QWidget *parent, bool button, const QColor &background );
  21. ~OglCameraWidget();
  22. public slots:
  23. void setScaling(int scale);
  24. void setLogo();
  25. void setTexture();
  26. void setShowBubbles(bool);
  27. void setTransparent(bool transparent);
  28. void setYaw(float Yaw){ m_fYaw = Yaw; };
  29. void setPitch(float Pitch){ m_fPitch = Pitch; };
  30. void setRoll(float Roll){ m_fRoll = Roll; };
  31. private slots:
  32. void handleButtonPress();
  33. void keyPressEvent(QKeyEvent *event);
  34. void mouseMoveEvent(QMouseEvent *event);
  35. void wheelEvent(QWheelEvent *event);
  36. protected:
  37. void resizeGL(int w, int h) Q_DECL_OVERRIDE;
  38. void paintGL() Q_DECL_OVERRIDE;
  39. void initializeGL() Q_DECL_OVERRIDE;
  40. private:
  41. void paintTexturedCube();
  42. void paintQtLogo();
  43. void createGeometry();
  44. //void createBubbles(int number);
  45. void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
  46. void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
  47. QWidget *m_pParent;
  48. QPoint m_slastPos;
  49. qreal m_fYaw, m_fPitch, m_fRoll;
  50. qreal m_fScale;
  51. QVector<QVector3D> m_vertices;
  52. QVector<QVector3D> m_normals;
  53. bool m_qtLogo;
  54. int m_frames;
  55. QTime m_time;
  56. QOpenGLShader *m_vshader1;
  57. QOpenGLShader *m_fshader1;
  58. QOpenGLShader *m_vshader2;
  59. QOpenGLShader *m_fshader2;
  60. QOpenGLShaderProgram *m_program1;
  61. QOpenGLShaderProgram *m_program2;
  62. QOpenGLTexture *m_texture;
  63. QOpenGLBuffer m_vbo1;
  64. QOpenGLBuffer m_vbo2;
  65. int m_vertexAttr1;
  66. int m_normalAttr1;
  67. int m_matrixUniform1;
  68. int m_vertexAttr2;
  69. int m_normalAttr2;
  70. int m_texCoordAttr2;
  71. int m_matrixUniform2;
  72. int m_textureUniform2;
  73. bool m_transparent;
  74. QPushButton *m_btn;
  75. bool m_hasButton;
  76. QColor m_background;
  77. };
  78. #endif