My custom QQuickItem currently does the following
- Create a QSGNode that subclasses QSGSimpleTextureNode
- In the nodes preprocess function, create a QOpenGLFramebufferObject to draw to
- Draw on the QOpenGLFramebufferObject using a QPainter
- Display the contents of the QOpenGLFramebufferObject as the node contents
The process I have for converting the FBO to a QSGTexture that I can set on the QSGSimpleTextureNode is the following.
QImage img = m_fbo->toImage();
QSGTexture* tex = m_window->createTextureFromImage(img, QQuickWindow::TextureCanUseAtlas);
setTexture(tex);
This seems very inefficient, and the app starts to get real framey even with relatively reasonable sized FBOs.
My questions are the following.
- Is there a simpler way of getting an FBO into a QSGTexture?
- Is there a better QPaintDevice compatible item that I should be using rather than a QOpenGLFramebufferObject?
- Is there a better subclass I should be extending than QSGSimpleTextureNode to do what I am wanting to do?
Thanks!