PlayerGLWidget.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef PLAYEROPENGLWIDGET_H
  2. #define PLAYEROPENGLWIDGET_H
  3. #include <QOpenGLWidget>
  4. #include <QOpenGLFunctions> // 添加此行
  5. #include <QOpenGLFunctions_3_3_Core> // 添加此行
  6. #include <QOpenGLTexture>
  7. #include "PlayerGlobalInfo.h"
  8. /**
  9. * @brief
  10. *
  11. */
  12. class PlayerGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_3_3_Core // 修改此行
  13. {
  14. Q_OBJECT
  15. enum
  16. {
  17. Left_Bottom_X,
  18. Left_Bottom_Y,
  19. Right_Bottom_X,
  20. Right_Bottom_Y,
  21. Right_Top_X,
  22. Right_Top_Y,
  23. Left_Top_X,
  24. Left_Top_Y,
  25. Pos_Max
  26. };
  27. public:
  28. explicit PlayerGLWidget(QWidget *parent = nullptr);
  29. ~PlayerGLWidget();
  30. /* 刷新一帧 */
  31. void updateFrame(Image_YUV420& image);
  32. /* 刷新一帧QImage */
  33. void updateFrame(Image_QImage& image);
  34. private:
  35. /* 转换成YUV420 */
  36. void convertQImageToYUV420(const QImage& image, Image_YUV420& yuv420);
  37. protected:
  38. void initializeGL() override;
  39. void resizeGL(int w, int h) override;
  40. void paintGL() override;
  41. // void setImage(const QImage &image);
  42. private:
  43. Image_QImage m_image;
  44. Image_YUV420 m_YUV420;
  45. QByteArray yData;
  46. QByteArray uData;
  47. QByteArray vData;
  48. QOpenGLTexture* textureY_;
  49. QOpenGLTexture* textureU_;
  50. QOpenGLTexture* textureV_;
  51. GLuint textureIdY_;
  52. GLuint textureIdU_;
  53. GLuint textureIdV_;
  54. QSize Ortho2DSize_;
  55. QSize imageSize_; // 添加此行
  56. GLuint shaderProgram; // 添加此行
  57. GLuint VAO, VBO, EBO; // 添加此行
  58. };
  59. #endif /* PLAYEROPENGLWIDGET_H */