I\'m starting out on using OpenGL with Qt, and with Shaders (I have OpenGL experience, but not with shaders yet)
I\'m following this tutorial: http://releases.qt-pro
I've got the same error on my macbook (early 2011), and this answer helps me. Basically you deprecate to version120.
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 );
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.