Qt5 OpenGL GLSL version error

谁说胖子不能爱 提交于 2019-11-28 11:40:49

Newer QOpenGLWidget doesn't support any constructor with QGLFormat. Instead, in your main.cpp, specify the default QSurfaceFormat for all QOpenGLWidget and QOpenGLContext as following:

// main.cpp
QSurfaceFormat glFormat;
glFormat.setVersion(3, 3);
glFormat.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(glFormat);

Now you should be able to use something like #version 330 core in your shader.

You should create an QGLFormat object and pass it to the QGLWidget as a constructor parameter. The QGLFormat object should be created as showed in the code below.

QGLFormat glFormat;
glFormat.setVersion( 3, 2 );
glFormat.setProfile( QGLFormat::CoreProfile );
xysun

I've got the same error on my macbook (early 2011), and this answer helps me. Basically you deprecate to version120.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!