RenderState#

Encapsulates the current rendering state during a call to updateUniformData() and the other update type of functions. More

Synopsis#

Functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

The render state contains a number of accessors that the shader needs to respect in order to conform to the current state of the scene graph.

class PySide6.QtQuick.QSGMaterialShader.RenderState#
PySide6.QtQuick.QSGMaterialShader.RenderState.DirtyState#

Constant

Description

QSGMaterialShader.RenderState.DirtyMatrix

(inherits enum.Flag) Used to indicate that the matrix has changed and must be updated.

QSGMaterialShader.RenderState.DirtyOpacity

Used to indicate that the opacity has changed and must be updated.

QSGMaterialShader.RenderState.DirtyCachedMaterialData

Used to indicate that the cached material state has changed and must be updated.

QSGMaterialShader.RenderState.DirtyAll

Used to indicate that everything needs to be updated.

PySide6.QtQuick.QSGMaterialShader.RenderState.combinedMatrix()#
Return type:

PySide6.QtGui.QMatrix4x4

Returns the matrix combined of modelview matrix and project matrix.

PySide6.QtQuick.QSGMaterialShader.RenderState.determinant()#
Return type:

float

Returns the modelview determinant to be used for rendering.

PySide6.QtQuick.QSGMaterialShader.RenderState.devicePixelRatio()#
Return type:

float

Returns the ratio between physical pixels and device-independent pixels to be used for rendering.

PySide6.QtQuick.QSGMaterialShader.RenderState.deviceRect()#
Return type:

PySide6.QtCore.QRect

Returns the device rect of the surface being rendered to

PySide6.QtQuick.QSGMaterialShader.RenderState.dirtyStates()#
Return type:

Combination of QSGMaterialShader.RenderState.DirtyState

Returns which rendering states that have changed and needs to be updated for geometry rendered with this material to conform to the current rendering state.

PySide6.QtQuick.QSGMaterialShader.RenderState.isMatrixDirty()#
Return type:

bool

Returns true if the dirtyStates() contain the dirty matrix state, otherwise returns false.

PySide6.QtQuick.QSGMaterialShader.RenderState.isOpacityDirty()#
Return type:

bool

Returns true if the dirtyStates() contains the dirty opacity state, otherwise returns false.

PySide6.QtQuick.QSGMaterialShader.RenderState.modelViewMatrix()#
Return type:

PySide6.QtGui.QMatrix4x4

Returns the model view matrix.

If the material has the RequiresFullMatrix flag set, this is guaranteed to be the complete transform matrix calculated from the scenegraph.

However, if this flag is not set, the renderer may choose to alter this matrix. For example, it may pre-transform vertices on the CPU and set this matrix to identity.

In a situation such as the above, it is still possible to retrieve the actual matrix determinant by setting the RequiresDeterminant flag in the material and calling the determinant() accessor.

PySide6.QtQuick.QSGMaterialShader.RenderState.opacity()#
Return type:

float

Returns the accumulated opacity to be used for rendering.

PySide6.QtQuick.QSGMaterialShader.RenderState.projectionMatrix()#
Return type:

PySide6.QtGui.QMatrix4x4

Returns the projection matrix.

PySide6.QtQuick.QSGMaterialShader.RenderState.resourceUpdateBatch()#
Return type:

QRhiResourceUpdateBatch

Returns a resource update batch to which upload and copy operatoins can be queued. This is typically used by updateSampledImage() to enqueue texture image content updates.

PySide6.QtQuick.QSGMaterialShader.RenderState.rhi()#
Return type:

QRhi

Returns the current QRhi.

PySide6.QtQuick.QSGMaterialShader.RenderState.uniformData()#
Return type:

PySide6.QtCore.QByteArray

Returns a pointer to the data for the uniform (constant) buffer in the shader. Uniform data must only be updated from updateUniformData() . The return value is null in the other reimplementable functions, such as, updateSampledImage() .

Note

It is strongly recommended to declare the uniform block with std140 in the shader, and to carefully study the standard uniform block layout as described in section 7.6.2.2 of the OpenGL specification. It is up to the QSGMaterialShader implementation to ensure data gets placed at the right location in this QByteArray, taking alignment requirements into account. Shader code translated to other shading languages is expected to use the same offsets for block members, even when the target language uses different packing rules by default.

Note

Avoid copying from C++ POD types, such as, structs, in order to update multiple members at once, unless it has been verified that the layouts of the C++ struct and the GLSL uniform block match.

PySide6.QtQuick.QSGMaterialShader.RenderState.viewportRect()#
Return type:

PySide6.QtCore.QRect

Returns the viewport rect of the surface being rendered to.