PlayerGLWidget2.h_ 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef PLAYEROPENGLWIDGET_H
  2. #define PLAYEROPENGLWIDGET_H
  3. #include <QOpenGLWidget>
  4. #include <QOpenGLFunctions>
  5. #include <QOpenGLShaderProgram>
  6. #include <QOpenGLTexture>
  7. #include <QTimer>
  8. #include "PlayerGlobalInfo.h"
  9. /**
  10. * @brief 可以播放,但是CPU占用率比纯CPU绘制还高
  11. *
  12. */
  13. class PlayerGLWidget : public QOpenGLWidget , public QOpenGLFunctions
  14. {
  15. Q_OBJECT
  16. public:
  17. explicit PlayerGLWidget(QWidget *parent = nullptr);
  18. ~PlayerGLWidget();
  19. /* 刷新一帧 */
  20. void updateFrame(Image_YUV420& image);
  21. /* 刷新一帧QImage */
  22. void updateFrame(Image_QImage& image);
  23. private:
  24. void initShaders();
  25. void initTextures();
  26. protected:
  27. void initializeGL() override;
  28. void resizeGL(int w, int h) override;
  29. void paintGL() override;
  30. // void setImage(const QImage &image);
  31. private:
  32. QVector<QVector3D> vertices;
  33. QVector<QVector2D> texCoords;
  34. QOpenGLShaderProgram program;
  35. QOpenGLTexture *texture;
  36. QMatrix4x4 projection;
  37. Image_QImage m_image;
  38. };
  39. #endif /* PLAYEROPENGLWIDGET_H */