Qt5 OpenGL GLSL version error

前端 未结 3 1247
渐次进展
渐次进展 2020-12-10 20:13

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

相关标签:
3条回答
  • 2020-12-10 20:32

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

    0 讨论(0)
  • 2020-12-10 20:37

    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 );
    
    0 讨论(0)
  • 2020-12-10 20:57

    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.

    0 讨论(0)
提交回复
热议问题