PlayerGLWidget(副本).h_ 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. class PlayerGLWidget : public QOpenGLWidget , public QOpenGLFunctions
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit PlayerGLWidget(QWidget *parent = nullptr);
  14. ~PlayerGLWidget();
  15. /* 刷新一帧 */
  16. void updateFrame(Image_YUV420& image);
  17. private:
  18. void initShaders();
  19. void initTextures();
  20. // void initVertex();
  21. // void initFrameBuffer();
  22. void renderYUV420P();
  23. protected:
  24. void initializeGL() override;
  25. void resizeGL(int w, int h) override;
  26. void paintGL() override;
  27. private:
  28. QOpenGLShaderProgram program;
  29. QOpenGLTexture *textureY = nullptr;
  30. QOpenGLTexture *textureU = nullptr;
  31. QOpenGLTexture *textureV = nullptr;
  32. QByteArray yData;
  33. QByteArray uData;
  34. QByteArray vData;
  35. int width = 0;
  36. int height = 0;
  37. };
  38. #endif /* PLAYEROPENGLWIDGET_H */