Qt 使用自带的 QOpenGLWidget 底层实现 用 glad.h 出现 #error OpenGL header already included, remove this include, glad already provides it(系统自动调用 Windos SDK GL/gl.h 导致和glad.h 重复)
只是调用 glad.h 文件, 而不是 gl.h 正确的结果应该是调用 我添加的glad.h 头文件。。。。。。
user16638088 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
将包含 glad.h 的头文件 添加在 #include 之前 就可以解决
enter image description here
example :
#include"base.h"==(include<glad/glad.h>)
#include<QOpenGLWidget>
#include<QTimer>
#include<QMouseEvent>
class TriangleWidget : public QOpenGLWidget
{
public:
TriangleWidget(QWidget *parent = nullptr);
protected:
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
private:
Render *ptr;
};
user16638088 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.