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. QOpenGLVertexArrayObject cannot use in openGL version 3.1 ?
Forum Updated to NodeBB v4.3 + New Features

QOpenGLVertexArrayObject cannot use in openGL version 3.1 ?

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 3.6k Views 1 Watching
  • 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.
  • H Offline
    H Offline
    hesheit
    wrote on 15 Aug 2013, 17:34 last edited by
    #1

    I try to render a simple triangle using opengl version 3.1 in Qt5.1. I used Vertex Array Object to encapsulate vertex states, but I found that the function create() of QOpenGLVertexArrayObject class didn't work.

    If I change the context version to 3.3, the function create() can be compiled, unfortunately my graphics card does not support version 3.3.

    I wonder that in Qt class reference (http://doc-snapshot.qt-project.org/qt5-stable/qtgui/qopenglvertexarrayobject.html), they say that "VAOs are supported as a core feature in OpenGL 3.0 or newer", so the version 3.1 should have worked. Does anyone know what I should do?

    Thank you in advance.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hesheit
      wrote on 15 Aug 2013, 18:03 last edited by
      #2

      Please Help Me...

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 15 Aug 2013, 19:48 last edited by
        #3

        Hi and welcome to devnet,

        Please allow at least 24 to 72 hours before bumping your own thread, not everybody on this forum live in the same timezone as you or even might have an answer to this specific question.

        In between you can also search the "bug report system":bugreports.qt-project.org/issues/ to see if someone reported something about this.
        The interest mailing list might also be a good place to search

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on 17 Aug 2013, 09:52 last edited by
          #4

          Which platform and OpenGL driver are you using please? Indeed this should work with OpenGL >= 3.0.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hesheit
            wrote on 17 Aug 2013, 10:35 last edited by
            #5

            Graphics Card : Intel HD Graphics 3000
            Platform : Mac OSX

            In the Intel website, they say this version of graphics card support opengl version 3.1.

            The problem occurs in the function .create() when the version of Surfaceformat is 3.1.

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZapB
              wrote on 17 Aug 2013, 11:41 last edited by
              #6

              Hmmm, are you sure that you are actually getting an OpenGL 3.1 context created? What does OpenGL report as the version number after you have created the context and made it current (glGetString(GL_VERSION))?

              Prior to OpenGL 3.0 VAO's are only available on OS X via the GL_APPLE_vertex_array_object extension which I unfortunately missed support for in the current implementation of QOpenGLVertexArrayObject. I will add this to an upcoming release of Qt.

              Nokia Certified Qt Specialist
              Interested in hearing about Qt related work

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hesheit
                wrote on 17 Aug 2013, 16:23 last edited by
                #7

                Hi ZapB

                I have just checked the opengl version from glGetString(GL_VERSION). This is the result
                OpenGL Version = 2.1 APPLE-7.32.12

                So, why didn't it change to the version I defined?
                This is my code.

                @GLWindow::GLWindow(QScreen* screen )
                : QWindow( screen ),
                m_scene(new GLShaderScene(this)),
                m_leftButtonPressed( false )
                {
                // Tell Qt we will use OpenGL for this window
                setSurfaceType( OpenGLSurface );

                // Specify the format we wish to use
                QSurfaceFormat format;
                format.setMajorVersion(3);
                format.setMinorVersion(1);
                format.setSamples(16);
                format.setProfile(QSurfaceFormat::CoreProfile);
                //format.setOption( QSurfaceFormat::DebugContext );
                
                resize( 800,600 );
                setFormat( format );
                create();
                
                // Create an OpenGL context
                m_context = new QOpenGLContext;
                m_context->setFormat( format );
                m_context->create();
                
                // Setup our scene
                m_context->makeCurrent( this );
                m_scene->setContext( m_context );
                initializeGL();
                
                // Make sure we tell OpenGL about new window sizes
                connect( this, SIGNAL( widthChanged( int ) ), this, SLOT( resizeGL() ) );
                connect( this, SIGNAL( heightChanged( int ) ), this, SLOT( resizeGL() ) );
                resizeGL();
                
                // This timer drives the scene updates
                QTimer* timer = new QTimer( this );
                connect( timer, SIGNAL( timeout() ), this, SLOT( updateScene() ) );
                timer->start( 16 );
                
                qDebug("OpenGL Version = %s", glGetString(GL_VERSION));
                

                }@

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hesheit
                  wrote on 17 Aug 2013, 16:53 last edited by
                  #8

                  When I changed the version to 3.2 or newer, as seen in the following code. The OpenGL version is "OpenGL Version = 3.2 INTEL-7.32.12"

                  But the viewport has no object rendered. When I try adding some codes for initializing OpenGL functions, it returns false (cannot initialize).

                  @GLWindow::GLWindow(QScreen* screen )
                  : QWindow( screen ),
                  m_scene(new GLShaderScene(this)),
                  m_leftButtonPressed( false )
                  {
                  // Tell Qt we will use OpenGL for this window
                  setSurfaceType( OpenGLSurface );

                  // Specify the format we wish to use
                  QSurfaceFormat format;
                  format.setMajorVersion(3);
                  format.setMinorVersion(2);
                  format.setSamples(16);
                  format.setProfile(QSurfaceFormat::CoreProfile);
                  //format.setOption( QSurfaceFormat::DebugContext );
                  
                  resize( 800,600 );
                  setFormat( format );
                  create();
                  
                  // Create an OpenGL context
                  m_context = new QOpenGLContext;
                  m_context->setFormat( format );
                  m_context->create();
                  
                  // Initialise opengl function
                  QOpenGLFunctions_3_2_Core *func = m_context->versionFunctions<QOpenGLFunctions_3_2_Core>();
                  if(!func->initializeOpenGLFunctions())
                      qDebug("Cannot initialise OpenGL function.");
                  
                  // Setup our scene
                  m_context->makeCurrent( this );
                  m_scene->setContext( m_context );
                  initializeGL();
                  
                  // Make sure we tell OpenGL about new window sizes
                  connect( this, SIGNAL( widthChanged( int ) ), this, SLOT( resizeGL() ) );
                  connect( this, SIGNAL( heightChanged( int ) ), this, SLOT( resizeGL() ) );
                  resizeGL();
                  
                  // This timer drives the scene updates
                  QTimer* timer = new QTimer( this );
                  connect( timer, SIGNAL( timeout() ), this, SLOT( updateScene() ) );
                  timer->start( 16 );
                  
                  qDebug("OpenGL Version = %s", glGetString(GL_VERSION));
                  

                  }@

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hesheit
                    wrote on 17 Aug 2013, 17:40 last edited by
                    #9

                    I now can fix it by using OpenGL 3.2 without initializing OpenGL function.
                    Vertex Array Object can now be used.
                    Thank you so much Zapb
                    ^^

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      ZapB
                      wrote on 17 Aug 2013, 18:21 last edited by
                      #10

                      You need to make the context current before initializing the functions object. It should work as expected then.

                      As for why you didn't get an OpenGL 3.1 context, either:

                      • A bug in Qt
                      • OS X doesn't support OpenGL 3.1 contexts

                      Not sure which it is without digging further.

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hesheit
                        wrote on 17 Aug 2013, 20:47 last edited by
                        #11

                        Now I can fix it without initializing.

                        But I dont know why opengl is set to the version 2.1 when I define the surface format to 3.1 or even the older version, but when I define it to 3.2 or newer, opengl is set to version 3.2.

                        I think OS X support only these two versions on my mac

                        Anyway, thanks very much

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          ZapB
                          wrote on 18 Aug 2013, 07:52 last edited by
                          #12

                          OS X Mountain Lion and Lion are limited to OpenGL 3.2 even if the hardware is capable of higher. OS X Mavericks will increase this to OpenGL 4.1 if your hardware supports it.

                          Nokia Certified Qt Specialist
                          Interested in hearing about Qt related work

                          1 Reply Last reply
                          0

                          1/12

                          15 Aug 2013, 17:34

                          • Login

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