Integrating custom OpenGL with QQuickFramebufferObject
Unsolved
QML and Qt Quick
-
I’d like to integrate my “custom” OpenGL drawing into QML via the QQuickFrameBufferObject approach described here. But I don't understand what Renderer::createFrameBufferObject() is supposed to return, given my current renderer. My custom renderer already maintains a VAO and three FBOs for vertices/colors, normals, and triangle-drawing indices:
/// Vertex Array Object, holds all information to render surfac QOpenGLVertexArrayObject *m_vao; /// Vertex buffer object holds surface vertex positions and colors QOpenGLBuffer *m_positionColorBuffer; /// Vertex buffer object holds surface normal vectors QOpenGLBuffer *m_normalBuffer; /// Index buffer object holds indices for triangle strips QOpenGLBuffer *m_indicesBuffer;
My renderer initializes these:
m_vao->create(); m_vao->bind(); m_positionColorBuffer->create(); m_positionColorBuffer->bind(); m_positionColorBuffer->allocate(position-colors data here); m_normalBuffer->create(); m_normalBuffer->bind(); m_normalBuffer->allocate(normal vectors here); m_indicesBuffer->create(); m_indicesBuffer->bind(); m_indicesBuffer->allocate(index-drawing list here); // compile shaders, set attribute buffers, etc.
My renderer's render method does this:
m_vao->bind(); glDrawElements(GL_TRIANGLES, m_indicesCount, GL_UNSIGNED_INT, 0) m_vao->release();
But the example shows return of a single QOpenGLFrameBufferObject:
class FbItemRenderer : public QQuickFramebufferObject::Renderer { QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) { QOpenGLFramebufferObjectFormat format; format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); // optionally enable multisampling by doing format.setSamples(4); return new QOpenGLFramebufferObject(size, format); }
So in my renderer's case, what should createFrameBufferObject() return?
Thanks!