QOpenGLVertexArrayObject cannot use in openGL version 3.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.



  • Please Help Me...


  • Lifetime Qt Champion

    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



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



  • 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.



  • 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.



  • 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));
    

    }@



  • 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));
    

    }@



  • 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
    ^^



  • 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.



  • 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



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.