Important: Please read the Qt Code of Conduct -

QOpenGLVertexArrayObject::create() fails inside a QQuickFramebufferObject::Renderer derived class

  • I have a class derived from QQuickFramebufferObject::Renderer which I use to render to a QQuickFramebufferObject. My application has a QML based UI but needs OpenGL rendering.

    I have got this currently to use VAOs with VBOs :
    @// VAO
    mVAO = new QOpenGLVertexArrayObject();
    if (!mVAO->create()) {
    qDebug() << "ERROR: VAO creation failed";

    // VBO
    mVBO = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
    if (!mVBO->create()) {
    qDebug() << "ERROR: VBO creation failed";
    mVBO->setUsagePattern( QOpenGLBuffer::StreamDraw );
    mVBO->allocate( mVertices.constData(), mVertices.count() * 3 * sizeof( float ) );
    mProgram.setAttributeBuffer(mVertexAttrLoc, GL_FLOAT, 0, 3 ); // uses the currently bound VBO

    // This is imp, we do not want any more state info recorded

    The mVAO->create() fails for some reason. Is there anyway to get more information from opengl about this error ?

    One other thing is I am using Qt 5.2 and a laptop with a dual video card and the nvidia optimus thingy. But I can see the program is executed by the nvidia card and not the onboard intel card. So it probably is not a hardware capabilities issue.

    The OpenGL version reported by qDebug() << "OpenGL version:" << QGLFormat::openGLVersionFlags();

    is OpenGL version: QFlags(0x800) which is QGLFormat::OpenGL_ES_Version_2_0

    Maybe the ES version is whats standard in laptops. I am guessing QOpenGLVertexArrayObject should work inside a QQuickFramebufferObject::Renderer class but maybe I need to try pure opengl instead ?

    I used this as a reference to write the code :

  • That's perfectly normal. You are using OpenGL (ES? that's somehow doubtful) 2.0 without support for vertex array objects. create() returns false in this case, indicating that VAOs are not supported with the current context. This is fine, just continue without VAOs.

    To use the examples in the references blog series, you need to request a OpenGL 3.x or 4.x context.

  • Ok, how do I request one ? By the time my QQuickFramebufferObject::Renderer gets created, a FBO is already created and bound.

  • Either stop relying on VAOs, i.e. set the vertex attributes every time (since mVAO->bind() will have no effect if VAOs are not supported) or do something like the following example (see lines starting from 159 and 204):

Log in to reply