Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5.10 Windows: Error: 'glVertexAttrib2fv' was not declared in this scope?
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 358 Views
  • 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 Offline
    E Offline
    Eager
    wrote on last edited by Eager
    #1

    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
    0
    • E Offline
      E Offline
      Eager
      wrote on last edited by
      #2

      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
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved