QSGAbstractRenderer Class | Qt Quick 5.5

- Qt 5.5
- Qt Quick
- C++ Classes
- QSGAbstractRenderer
- Qt 5.5.1 Reference Documentation

# QSGAbstractRenderer Class

QSGAbstractRenderer gives access to the scene graph nodes and rendering of a QSGEngine. More...

Header: | #include <QSGAbstractRenderer>
qmake: | QT += quick
Since: | Qt 5.4
Inherits: | QObject
Inherited By: |

- List of all members, including inherited members

## Public Types

flags | ClearMode
enum | ClearModeBit { ClearColorBuffer, ClearDepthBuffer, ClearStencilBuffer }

## Public Functions

QColor | clearColor() const
ClearMode | clearMode() const
QRect | deviceRect() const
QMatrix4x4 | projectionMatrix() const
virtual void | renderScene(GLuint fboId = 0) = 0
QSGRootNode * | rootNode() const
void | setClearColor(const QColor & color)
void | setClearMode(ClearMode mode)
void | setDeviceRect(const QRect & rect)
void | setDeviceRect(const QSize & size)
void | setProjectionMatrix(const QMatrix4x4 & matrix)
void | setProjectionMatrixToRect(const QRectF & rect)
void | setRootNode(QSGRootNode * node)
void | setViewportRect(const QRect & rect)
void | setViewportRect(const QSize & size)
QRect | viewportRect() const

- 31 public functions inherited from QObject

## Signals

void | sceneGraphChanged()

- 2 signals inherited from QObject

### Additional Inherited Members

- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

QSGAbstractRenderer gives access to the scene graph nodes and rendering of a QSGEngine.

A QSGAbstractRenderer created by a QSGEngine allows you to set your QSGNode tree through setRootNode() and control the rendering viewport through setDeviceRect(), setViewportRect() and setProjectionMatrixToRect(). You can finally trigger the rendering to the desired framebuffer through renderScene().

The QSGAbstractRenderer is only available when used with a QSGEngine and isn't exposed when used internally by QQuickWindow.

See also QSGEngine and QSGNode.

## Member Type Documentation

### enum QSGAbstractRenderer::ClearModeBit
flags QSGAbstractRenderer::ClearMode

Used with setClearMode() to indicate which buffer should be cleared before the scene render.

Constant | Value | Description
--- | --- | ---
`QSGAbstractRenderer::ClearColorBuffer` | `0x0001` | Clear the color buffer using clearColor().
`QSGAbstractRenderer::ClearDepthBuffer` | `0x0002` | Clear the depth buffer.
`QSGAbstractRenderer::ClearStencilBuffer` | `0x0004` | Clear the stencil buffer.

The ClearMode type is a typedef for QFlags<ClearModeBit>. It stores an OR combination of ClearModeBit values.

See also setClearMode() and setClearColor().

## Member Function Documentation

### QColor QSGAbstractRenderer::clearColor() const

Returns the color that clears the framebuffer at the beginning of the rendering.

See also setClearColor() and clearMode().

### ClearMode QSGAbstractRenderer::clearMode() const

Flags defining which attachment of the framebuffer will be cleared before each scene render.

See also setClearMode() and clearColor().

### QRect QSGAbstractRenderer::deviceRect() const

Returns the device rect of the surface being rendered to.

See also setDeviceRect().

### QMatrix4x4 QSGAbstractRenderer::projectionMatrix() const

Returns the projection matrix

See also setProjectionMatrix() and setProjectionMatrixToRect().

### `[pure virtual]` void QSGAbstractRenderer::renderScene(GLuint fboId = 0)

Render the scene to the specified fboId

If fboId isn't specified, the scene graph will be rendered to the default framebuffer. You will have to call QOpenGLContext::swapBuffers() yourself afterward.

The framebuffer specified by fboId will be bound automatically.

See also QOpenGLContext::swapBuffers() and QOpenGLFramebufferObject::handle().

### QSGRootNode * QSGAbstractRenderer::rootNode() const

Returns the root of the QSGNode scene.

See also setRootNode().

### `[signal]` void QSGAbstractRenderer::sceneGraphChanged()

This signal is emitted on the first modification of a node in the tree after the last scene render.

### void QSGAbstractRenderer::setClearColor(const QColor & color)

Use color to clear the framebuffer when clearMode() is set to QSGAbstractRenderer::ClearColorBuffer.

See also clearColor() and setClearMode().

### void QSGAbstractRenderer::setClearMode(ClearMode mode)

Defines which attachment of the framebuffer should be cleared before each scene render with the mode flag.

See also clearMode() and setClearColor().

### void QSGAbstractRenderer::setDeviceRect(const QRect & rect)

Sets rect as the geometry of the surface being rendered to.

See also deviceRect().

### void QSGAbstractRenderer::setDeviceRect(const QSize & size)

This is an overloaded function.

Sets the size of the surface being rendered to.

See also deviceRect().

### void QSGAbstractRenderer::setProjectionMatrix(const QMatrix4x4 & matrix)

Use matrix to project the QSGNode coordinates onto surface pixels.

See also projectionMatrix() and setProjectionMatrixToRect().

### void QSGAbstractRenderer::setProjectionMatrixToRect(const QRectF & rect)

Convenience method that calls setProjectionMatrix() with an orthographic matrix generated from rect.

See also setProjectionMatrix() and projectionMatrix().

### void QSGAbstractRenderer::setRootNode(QSGRootNode * node)

Sets the node as the root of the QSGNode scene that you want to render. You need to provide a node before trying to render the scene.

Note: This doesn't take ownership of node.

See also rootNode().

### void QSGAbstractRenderer::setViewportRect(const QRect & rect)

Sets rect as the geometry of the viewport to render on the surface.

See also viewportRect().

### void QSGAbstractRenderer::setViewportRect(const QSize & size)

This is an overloaded function.

Sets the size of the viewport to render on the surface.

See also viewportRect().

### QRect QSGAbstractRenderer::viewportRect() const

Returns the rect of the viewport to render.

See also setViewportRect().