QOpenGLVertexArrayObject::create() fails inside a QQuickFramebufferObject::Renderer derived class
-
wrote on 9 Mar 2014, 15:15 last edited by
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";
}
mVAO->bind();// VBO
mVBO = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
if (!mVBO->create()) {
qDebug() << "ERROR: VBO creation failed";
}
mVBO->setUsagePattern( QOpenGLBuffer::StreamDraw );
mVBO->bind();
mVBO->allocate( mVertices.constData(), mVertices.count() * 3 * sizeof( float ) );
mProgram.enableAttributeArray(mVertexAttrLoc);
mProgram.setAttributeBuffer(mVertexAttrLoc, GL_FLOAT, 0, 3 ); // uses the currently bound VBO// This is imp, we do not want any more state info recorded
mVAO->release();@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 : http://www.kdab.com/opengl-in-qt-5-1-part-2/
-
wrote on 10 Mar 2014, 08:43 last edited by
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.
-
wrote on 10 Mar 2014, 18:07 last edited by
Ok, how do I request one ? By the time my QQuickFramebufferObject::Renderer gets created, a FBO is already created and bound.
-
wrote on 12 Mar 2014, 11:30 last edited by
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):
1/4