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(0×800) 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/
↧