QQuickFrameBufferObject

The QQuickFramebufferObject allows us to wrap custom OpenGL code in a QML item. The rendering gets redirected off screen to an OpenGL frame buffer object and Qt creates the required scene graph object to accomplish that. The following example shows the basic usage:

class FrameBufferTriangle : public QQuickFramebufferObject{public:   Renderer* createRenderer() const override;  ...};class FrameBufferTriangleRenderer : public QQuickFramebufferObject::Renderer{public:  void synchronize(QQuickFramebufferObject *item) override;   QOpenGLFramebufferObject *createFramebufferObject(const QSize &s) override;   void render() override  {    QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();    // use OpenGL functions f->glClearColor(1,1,1,0); ...

Get Hands-On High Performance Programming with Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.