#ifndef PLAYEROPENGLWIDGET2_H
#define PLAYEROPENGLWIDGET2_H


#include <QOpenGLWidget>
#include <QOpenGLFunctions_3_3_Core>
#include <cstdint>
#include <GL/gl.h>
#include <qchar.h>
#include <qimage.h>


/**
 * @brief 
 * 
 */


class PlayerGLWidget2 : public QOpenGLWidget, protected QOpenGLFunctions_3_3_Core
{
    Q_OBJECT

public:
    explicit PlayerGLWidget2(QWidget *parent = nullptr);
    ~PlayerGLWidget2();



 
protected:
    void initializeGL() override;
    void resizeGL(int w, int h) override;
    void paintGL() override;

private:
    /* 打开GLSL文件，读取着色器代码 */
    bool loadShaderCode(const QString &fileName, char** shaderCode);
    /* 加载图片 */
    bool loadImage(const QString &fileName, QImage &imageTexture);

private:

    GLuint m_VAO1 = 0;              // 顶点数组对象的ID
    GLuint m_VBO1 = 0;              // 顶点缓冲对象的ID
    GLuint m_texture1;              // 纹理对象1
    GLuint m_texture2;              // 纹理对象2
    GLuint m_EBO1 = 0;              // 索引缓冲对象的ID
    GLuint m_shaderProgram = 0;     // 着色器程序对象的ID

    float* m_vertices = nullptr;    // 顶点数据
    int m_vertexCount = 0;          // 顶点数量
    int m_vertexSize = 0;           // 顶点大小

    uint32_t* m_indices = nullptr;  // 索引数据(EBO数据)
    int m_indexCount = 0;           // 索引数量

    char* m_vertexShaderCode = nullptr;     // 顶点着色器代码
    char* m_fragmentShaderCode = nullptr;   // 片段着色器代码

    QImage m_imageTexture;          /* 纹理图片 */
    QImage m_imageTexture2;         /* 纹理图片2 */
};



#endif /* PLAYEROPENGLWIDGET2_H */
