timer())); } mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QGLWidget> #include <QOpenGLFunctions _3_0> class MainWindow : public QGLWidget,QOpenGLFunctions_3_0 { Q_OBJECT public: explicit MainWindow a.exec(); } mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QGLWidget> #include <QOpenGLFunctions _3_0> class MainWindow : public QGLWidget,QOpenGLFunctions_3_0 { Q_OBJECT public: explicit MainWindow
20Hello%20Triangle/ 程序参考地址: https://blog.csdn.net/z136411501/article/details/79834381 这里介绍第二种方法,使用QOpenGLFunctions 头文件如下: #include <QOpenGLWidget> #include <QOpenGLFunctions_3_3_Core> class MyGLWidget : public QOpenGLWidget VBO; GLuint VAO; GLuint EBO; GLuint m_shaderProgram; //着色器程序对象 QOpenGLFunctions void MyGLWidget::initializeGL() { m_core = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions
QtWidgets import QApplication, QMainWindowfrom PyQt5.QtGui import QOpenGLWindowfrom PyQt5.QtOpenGL import QOpenGLFunctions initializeGL(self): # 初始化 OpenGL 函数 self.gl = self.opengl_widget.context().versionFunctions(QOpenGLFunctions PyQt5.QtGui import QOpenGLWindow, QPainter, QPenfrom PyQt5.QtCore import Qtfrom PyQt5.QtOpenGL import QOpenGLFunctions ] def initializeGL(self): self.gl = self.opengl_widget.context().versionFunctions(QOpenGLFunctions
MYGLWIDGET_H #include <QMainWindow> #include <QObject> #include <QWidget> #include <QOpenGLWidget> #include <QOpenGLFunctions QOpenGLBuffer> #include <QOpenGLVertexArrayObject> class myGlWidget : public QOpenGLWidget , protected QOpenGLFunctions
Checking to see if the _QOpenGLFunctions_2_0 module should be built... Checking to see if the _QOpenGLFunctions_2_1 module should be built... Checking to see if the _QOpenGLFunctions_4_1_Core module should be built...
模块的一系列类 在 Qt 4 的 QtOpenGL 模块中最有用的类被移动到 QtGui 模块中了,例如 QOpenGLFramebufferObject、QOpenGLShaderProgram、QOpenGLFunctions
让我们检查一下glpanel.h头文件中的GLPanel类的声明: class GLPanel : public QOpenGLWidget, protected QOpenGLFunctions : GLuint vbo; GLuint vao; GLuint shaderProg; }; 该类派生自两个类:QOpenGLWidget类和QOpenGLFunctions QOpenGLFunctions_4_2_Core类包含许多函数,它们的名称与 Khronos 的 OpenGL V4.2 API 相似。 由于我们使用QOpenGLFunctions_4_2_Core类,因此将版本设置为 V4.2。 除了QOpenGLFunctions_*类中的 OpenGL API 函数外,Qt 还为 OpenGL 中的概念包装了许多其他类。