Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Qt5.10 Windows: Error: 'glVertexAttrib2fv' was not declared in this scope?

    General and Desktop
    1
    2
    218
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      Eager last edited by Eager

      I am trying to port my OpenGL project from GLFW to Qt 5.10.1 on Windows using MinGW but I am facing some issues. Everything was working perfect until I needed to use glVertexAttrib2fv which Qt says "was not declared in this scope"! I don't know what am I missing.

      main.cpp

      QSurfaceFormat format;
      format.setVersion(4, 3);
      format.setProfile(QSurfaceFormat::CoreProfile);
      format.setDepthBufferSize(24);
      format.setStencilBufferSize(8);
      format.setSamples(10); 
      QSurfaceFormat::setDefaultFormat(format);
      

      myopenglwidget.h:

      #include <QWidget>
      #include <QOpenGLWidget>
      #include <QOpenGLFunctions_4_3_Core>
      #include <QOpenGLShaderProgram>
      
      class MyOpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_3_Core
      {
      protected:
          void initializeGL();
      ...
      }
      
      void MyOpenGLWidget::initializeGL()
      {
          // initialize OpenGL Functions
          initializeOpenGLFunctions();
      ...
      }
      

      glVertexAttrib2fv is supported in all versions of OpenGL: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glVertexAttrib.xhtml

      Ask If more information is needed to solve this problem.

      1 Reply Last reply Reply Quote 0
      • E
        Eager last edited by

        I found the solution, the trick was to use CompatibilityProfile rather than CoreProfile!

        main.cpp

        QSurfaceFormat format;
        format.setVersion(4, 3);
        format.setProfile(QSurfaceFormat::CompatibilityProfile);
        format.setDepthBufferSize(24);
        format.setStencilBufferSize(8);
        format.setSamples(10); 
        QSurfaceFormat::setDefaultFormat(format);
        

        myopenglwidget.h:

        #include <QWidget>
        #include <QOpenGLWidget>
        #include <QOpenGLFunctions_4_3_Compatibility>
        #include <QOpenGLShaderProgram>
        
        class MyOpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_3_Compatibility
        {
        ...
        }
        
        1 Reply Last reply Reply Quote 1
        • E
          Eager last edited by

          I found the solution, the trick was to use CompatibilityProfile rather than CoreProfile!

          main.cpp

          QSurfaceFormat format;
          format.setVersion(4, 3);
          format.setProfile(QSurfaceFormat::CompatibilityProfile);
          format.setDepthBufferSize(24);
          format.setStencilBufferSize(8);
          format.setSamples(10); 
          QSurfaceFormat::setDefaultFormat(format);
          

          myopenglwidget.h:

          #include <QWidget>
          #include <QOpenGLWidget>
          #include <QOpenGLFunctions_4_3_Compatibility>
          #include <QOpenGLShaderProgram>
          
          class MyOpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_3_Compatibility
          {
          ...
          }
          
          1 Reply Last reply Reply Quote 1
          • First post
            Last post