PySide6.QtQuick.QQuickRenderTarget¶
- class QQuickRenderTarget¶
- The - QQuickRenderTargetclass provides an opaque container for native graphics resources specifying a render target, and associated metadata.- Details- See also - Synopsis¶- Methods¶- def - __init__()
- def - depthTexture()
- def - isNull()
- def - __ne__()
- def - __eq__()
 - Static 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 - class Flag¶
- (inherits - enum.Flag) Flags for the static- QQuickRenderTargetconstructor functions.- Constant - Description - QQuickRenderTarget.Flag.Flag.MultisampleResolve - Indicates that the - sampleCountargument 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- sampleCountargument is greater than 1, it implies the provided texture is multisample. The flag has no effect is the- sampleCountis 1 (indicating that multisampling is not involved).- Added in version 6.8. 
 - __init__()¶
 - Constructs a default - QQuickRenderTargetthat does not reference any native objects.- __init__(other)
- Parameters:
- other – - QQuickRenderTarget
 
 - depthTexture()¶
- Return type:
- QRhiTexture
 
 - Returns the currently set depth texture or, in most cases, - None.- The value is only non-null when - setDepthTexture()was called.- See also - devicePixelRatio()¶
- Return type:
- 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. - See also - static fromOpenGLRenderBuffer(renderbufferId, pixelSize[, sampleCount=1])¶
- Parameters:
- renderbufferId – int 
- pixelSize – - QSize
- sampleCount – int 
 
- Return type:
 
 - Returns a new - QQuickRenderTargetreferencing 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. - pixelSizespecifies the size of the image, in pixels.- sampleCountspecifies 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 - QQuickRenderTargetdoes 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.- See also - static fromOpenGLTexture(textureId, pixelSize[, sampleCount=1])¶
- Parameters:
- textureId – int 
- pixelSize – - QSize
- sampleCount – int 
 
- Return type:
 
 - Returns a new - QQuickRenderTargetreferencing an OpenGL texture object specified by- textureId. The texture is assumed to have a format of GL_RGBA (GL_RGBA8).- pixelSizespecifies the size of the image, in pixels. Currently only 2D textures are supported.- sampleCountspecifies 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 - textureIdmust be a valid name in the rendering context used by the Qt Quick scenegraph.- Note - the resulting - QQuickRenderTargetdoes 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.- See also - static fromOpenGLTexture(textureId, format, pixelSize[, sampleCount=1])
- Parameters:
- textureId – int 
- format – int 
- pixelSize – - QSize
- sampleCount – int 
 
- Return type:
 
 - Returns a new - QQuickRenderTargetreferencing an OpenGL texture object specified by- textureId.- formatspecifies the native internal format of the texture. Only texture formats that are supported by Qt’s rendering infrastructure should be used.- pixelSizespecifies the size of the image, in pixels. Currently only 2D textures are supported.- sampleCountspecifies 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 - textureIdmust be a valid name in the rendering context used by the Qt Quick scenegraph.- Note - the resulting - QQuickRenderTargetdoes 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.- See also - static fromOpenGLTexture(textureId, format, pixelSize, sampleCount, arraySize, flags)
- Parameters:
- Return type:
 
 - Returns a new - QQuickRenderTargetreferencing an OpenGL 2D texture or texture array object specified by- textureId.- formatspecifies the native internal format of the texture. Only texture formats that are supported by Qt’s rendering infrastructure should be used.- pixelSizespecifies the size of the image, in pixels. Currently only 2D textures and 2D texture arrays are supported.- sampleCountspecifies 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- flagscontains- MultisampleResolve. In that case,- textureIdis assumed to be a non-multisample 2D texture or 2D texture array, and- sampleCountdefines the number of samples desired. The resulting- QQuickRenderTargetwill 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 - arraySizeis greater than 1, it implies multiview rendering ( GL_OVR_multiview , QRhiColorAttachment::setMultiViewCount()), which can be relevant with VR/AR especially. In this case- arraySizeis 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 - textureIdmust be a valid 2D texture name in the rendering context used by the Qt Quick scenegraph. When- arraySizeis greater than 1,- textureIdmust be a valid 2D texture array name.- Note - the resulting - QQuickRenderTargetdoes 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) - static fromPaintDevice(device)¶
- Parameters:
- device – - QPaintDevice
- Return type:
 
 - Returns a new - QQuickRenderTargetreferencing a paint device object specified by- device.- This option of redirecting rendering to a QPaintDevice is available only when running with the - softwarebackend of Qt Quick.- Note - The - QQuickRenderTargetdoes not take ownship of- device, it is the caller’s responsibility to ensure the object exists as long as necessary.- See also - static fromRhiRenderTarget(renderTarget)¶
- Parameters:
- renderTarget – - QRhiRenderTarget
- Return type:
 
 - Returns a new - QQuickRenderTargetreferencing an existing- renderTarget.- renderTargetwill in most cases be a QRhiTextureRenderTarget, which allows directing the Qt Quick scene’s rendering into a QRhiTexture.- Note - the resulting - QQuickRenderTargetdoes not own- renderTargetand any underlying 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 referenced resources exists as long as necessary.- See also - isNull()¶
- Return type:
- bool 
 
 - Returns true if this - QQuickRenderTargetis default constructed, referencing no native objects.- mirrorVertically()¶
- Return type:
- bool 
 
 - Returns Returns whether the render target is mirrored vertically. - The default value is - false.- See also - __ne__(rhs)¶
- Parameters:
- rhs – - QQuickRenderTarget
- Return type:
- bool 
 
 - Returns true if - aand- brefer to a different set of native objects, or the associated data (size, sample count) does not match.- __eq__(rhs)¶
- Parameters:
- rhs – - QQuickRenderTarget
- Return type:
- bool 
 
 - Returns true if - aand- brefer to the same set of native objects and have matching associated data (size, sample count).- setDepthTexture(texture)¶
- Parameters:
- texture – - QRhiTexture
 
 - Requests using the given - textureas the depth or depth-stencil buffer. Ownership of- textureis not taken.- The request is only taken into account when relevant. For example, calling this function has no effect with - fromRhiRenderTarget(),- fromPaintDevice(), or- fromOpenGLRenderBuffer().- Normally a depth-stencil buffer is created automatically, transparently to the user of - QQuickRenderTarget. Therefore, there is no need to call this function in most cases when working with- QQuickRenderTarget. In special circumstances, it can however become essential to be able to provide a texture to render depth (or depth and stencil) data into, instead of letting Qt Quick create its own intermediate textures or buffers. An example of this is OpenXR and its extensions such as XR_KHR_composition_layer_depth . In order to “submit the depth buffer” to the XR compositor, one has to, in practice, retrieve an already created depth (depth-stencil) texture from OpenXR (from the XrSwapchain) and use that texture as the render target for depth data. That would not be possible without this function.- Note - The - textureis always expected to be a non-multisample 2D texture or texture array (for multiview). If MSAA is involved, the samples are resolved into- textureat the end of the render pass, regardless of having the- MultisampleResolveflag set or not. MSAA is only supported for depth (depth-stencil) textures when the underlying 3D API supports this, and this support is not universally available. See the relevant QRhi feature flag for details. When this is not supported and multisampling is requested in combination with a custom depth texture,- textureis not going to be touched during rendering and a warning is printed.- Note - When it comes to OpenGL and OpenGL ES, using depth textures is not functional on OpenGL ES 2.0 and requires at least OpenGL ES 3.0. Multisample (MSAA) support is not available without at least OpenGL ES 3.1, or OpenGL 3.0 on desktop. - See also - setDevicePixelRatio(ratio)¶
- Parameters:
- ratio – 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(enable)¶
- Parameters:
- enable – bool 
 
 - Sets the size of the render target contents should be mirrored vertically to - enablewhen drawing. This allows easy integration of third-party rendering code that does not follow the standard expectations.