PlayerGLWidget.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef PLAYEROPENGLWIDGET_H
  2. #define PLAYEROPENGLWIDGET_H
  3. #include <QOpenGLWidget>
  4. #include <QOpenGLFunctions>
  5. #include <QOpenGLShaderProgram>
  6. #include <QOpenGLTexture>
  7. #include "PlayerGlobalInfo.h"
  8. /**
  9. * @brief
  10. *
  11. */
  12. class PlayerGLWidget : public QOpenGLWidget , public QOpenGLFunctions
  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. protected:
  36. void initializeGL() override;
  37. void resizeGL(int w, int h) override;
  38. void paintGL() override;
  39. // void setImage(const QImage &image);
  40. private:
  41. uchar* imageData_; //纹理显示的数据源
  42. QSize imageSize_; //图片尺寸
  43. QSize Ortho2DSize_; //窗口尺寸
  44. QOpenGLTexture* texture_;
  45. GLuint textureId_; //纹理对象ID
  46. int vertexPos_[Pos_Max]; //窗口坐标
  47. float texturePos_[Pos_Max]; //纹理坐标
  48. Image_QImage m_image;
  49. };
  50. #endif /* PLAYEROPENGLWIDGET_H */