平台:银河麒麟
本文介绍如何在Qt框架下获取OpenGL的版本,参考了Qt获取OpenGL版本_芒果黑的博客-优快云博客_qt 获取opengl版本
代码:
#include <QApplication>
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QOffscreenSurface surf;
surf.create();
QOpenGLContext ctx;
ctx.create();
ctx.makeCurrent(&surf);
GLint major, minor;
ctx.functions()->glGetIntegerv(GL_MAJOR_VERSION, &major);
ctx.functions()->glGetIntegerv(GL_MINOR_VERSION, &minor);
qDebug()<<"OpenGL Version Info:" <<(const char *)ctx.functions()->glGetString(GL_VERSION);
qDebug()<<"OpenGL Version Major:" <<major<<"OpenGL minor:"<<minor;
ctx.doneCurrent();
return a.exec();
}
效果: