QQuickRenderTarget — PyQt Documentation v6.9.0 (original) (raw)
PyQt6.QtQuick.QQuickRenderTarget
Description¶
The QQuickRenderTarget class provides an opaque container for native graphics resources specifying a render target, and associated metadata.
Enums¶
Flag
Flags for the static QQuickRenderTarget constructor functions.
Member | Value | Description |
---|---|---|
MultisampleResolve | 0x01 | Indicates that the sampleCount argument is not the number of samples for the provided texture (and that the texture is still a non-multisample texture), but rather the desired samples for multisample antialiasing. Triggers automatically creating and managing an intermediate multisample texture (or texture array) as the color buffer, transparently to the application. The samples are resolved into the provided texture at the end of the render pass automatically. When this flag is not set, and the sampleCount argument is greater than 1, it implies the provided texture is multisample. The flag has no effect is the sampleCount is 1 (indicating that multisampling is not involved). |
Methods¶
__init__()
Constructs a default QQuickRenderTarget that does not reference any native objects.
__init__(QQuickRenderTarget)
TODO
devicePixelRatio() → float
Returns the device pixel ratio for the render target. This is the ratio between device pixels and device independent pixels.
The default device pixel ratio is 1.0.
__eq__(QQuickRenderTarget) → bool
TODO
@staticmethod
fromOpenGLRenderBuffer(int, QSize, sampleCount: int = 1) → QQuickRenderTarget
Returns a new QQuickRenderTarget referencing an OpenGL renderbuffer object specified by renderbufferId.
The renderbuffer will be used as the color attachment for the internal framebuffer object. This function is provided to allow targeting renderbuffers that are created by the application with some external buffer underneath, such as an EGLImageKHR. Once the application has called glEGLImageTargetRenderbufferStorageOES, the renderbuffer can be passed to this function.
pixelSize specifies the size of the image, in pixels.
sampleCount specific the number of samples. 0 or 1 means no multisampling, while a value like 4 or 8 states that the native object is a multisample renderbuffer.
Note: the resulting QQuickRenderTarget does not own any native resources, it merely contains references and the associated metadata of the size and sample count. It is the caller’s responsibility to ensure that the native resource exists as long as necessary.
@staticmethod
fromOpenGLTexture(int, QSize, sampleCount: int = 1) → QQuickRenderTarget
This is an overloaded function.
Returns a new QQuickRenderTarget referencing an OpenGL texture object specified by textureId. The texture is assumed to have a format of GL_RGBA (GL_RGBA8).
pixelSize specifies the size of the image, in pixels. Currently only 2D textures are supported.
sampleCount specific the number of samples. 0 or 1 means no multisampling, while a value like 4 or 8 states that the native object is a multisample texture.
The texture is used as the first color attachment of the render target used by the Qt Quick scenegraph. A depth-stencil buffer, if applicable, is created and used automatically.
The OpenGL object name textureId must be a valid name in the rendering context used by the Qt Quick scenegraph.
Note: the resulting QQuickRenderTarget does not own any native resources, it merely contains references and the associated metadata of the size and sample count. It is the caller’s responsibility to ensure that the native resource exists as long as necessary.
@staticmethod
fromOpenGLTexture(int, int, QSize, sampleCount: int = 1) → QQuickRenderTarget
Returns a new QQuickRenderTarget referencing an OpenGL texture object specified by textureId.
format specifies the native internal format of the texture. Only texture formats that are supported by Qt’s rendering infrastructure should be used.
pixelSize specifies the size of the image, in pixels. Currently only 2D textures are supported.
sampleCount specific the number of samples. 0 or 1 means no multisampling, while a value like 4 or 8 states that the native object is a multisample texture.
The texture is used as the first color attachment of the render target used by the Qt Quick scenegraph. A depth-stencil buffer, if applicable, is created and used automatically.
The OpenGL object name textureId must be a valid name in the rendering context used by the Qt Quick scenegraph.
Note: the resulting QQuickRenderTarget does not own any native resources, it merely contains references and the associated metadata of the size and sample count. It is the caller’s responsibility to ensure that the native resource exists as long as necessary.
@staticmethod
fromOpenGLTexture(int, int, QSize, int, int, Flag) → QQuickRenderTarget
This is an overloaded function.
Returns a new QQuickRenderTarget referencing an OpenGL 2D texture or texture array object specified by textureId.
format specifies the native internal format of the texture. Only texture formats that are supported by Qt’s rendering infrastructure should be used.
pixelSize specifies the size of the image, in pixels. Currently only 2D textures and 2D texture arrays are supported.
sampleCount specifies the number of samples. 0 or 1 means no multisampling, while a value like 4 or 8 states that the native object is a multisample texture, except when flags contains MultisampleResolve. In that case, textureId is assumed to be a non-multisample 2D texture or 2D texture array, and sampleCount defines the number of samples desired. The resulting QQuickRenderTarget will use an intermediate, automatically created multisample texture (or texture array) as its color attachment, and will resolve the samples into textureId. This is the recommended approach to perform MSAA when the native OpenGL texture is not already multisample.
When arraySize is greater than 1, it implies multiview rendering (GL_OVR_multiview, QRhiColorAttachment::setMultiViewCount()), which can be relevant with VR/AR especially. In this case arraySize is the number of views, typically 2
. See viewCount() for details on enabling multiview rendering within the Qt Quick scenegraph.
A depth-stencil buffer, if applicable, is created and used automatically. When the color buffer is multisample, the depth-stencil buffer will automatically be multisample too. For multiview rendering, the depth-stencil texture will automatically be made an array with a matching arraySize.
The OpenGL object name textureId must be a valid 2D texture name in the rendering context used by the Qt Quick scenegraph. When arraySize is greater than 1, textureId must be a valid 2D texture array name.
Note: the resulting QQuickRenderTarget does not own any native resources, it merely contains references and the associated metadata of the size and sample count. It is the caller’s responsibility to ensure that the native resource exists as long as necessary.
Note: The implementation of this overload is not compatible with OpenGL ES 2.0 or 3.0, and requires OpenGL ES 3.1 at minimum. (or OpenGL 3.0 on desktop)
@staticmethod
fromPaintDevice(QPaintDevice) → QQuickRenderTarget
Returns a new QQuickRenderTarget referencing a paint device object specified by device.
This option of redirecting rendering to a QPaintDevice is available only when running with the software
backend of Qt Quick.
Note: The QQuickRenderTarget does not take ownship of device, it is the caller’s responsibility to ensure the object exists as long as necessary.
isNull() → bool
Returns true if this QQuickRenderTarget is default constructed, referencing no native objects.
mirrorVertically() → bool
Returns Returns whether the render target is mirrored vertically.
The default value is false
.
__ne__(QQuickRenderTarget) → bool
TODO
setDevicePixelRatio(float)
Sets the device pixel ratio for this render target to ratio. This is the ratio between device pixels and device independent pixels.
Note that the specified device pixel ratio value will be ignored if renderWindow() is re-implemented to return a valid QWindow.
See also
setMirrorVertically(bool)
Sets the size of the render target contents should be mirrored vertically to enable when drawing. This allows easy integration of third-party rendering code that does not follow the standard expectations.
Note: This function should not be used when using the software
backend.
See also