QQuickRenderTarget Class

The QQuickRenderTarget class provides an opaque container for native graphics resources specifying a render target, and associated metadata. 更多...

头: #include <QQuickRenderTarget>
CMake: find_package(Qt6 REQUIRED COMPONENTS Quick)
target_link_libraries(mytarget PRIVATE Qt6::Quick)
qmake: QT += quick
Since: Qt 6.0

公共函数

QQuickRenderTarget ()
~QQuickRenderTarget ()
(since 6.3) qreal devicePixelRatio () const
bool isNull () const
(从 6.4 起) bool mirrorVertically () const
(since 6.3) void setDevicePixelRatio (qreal ratio )
(从 6.4 起) void setMirrorVertically (bool enable )

静态公共成员

(从 6.4 起) QQuickRenderTarget fromD3D11Texture (void * texture , uint format , const QSize & pixelSize , int sampleCount = 1)
QQuickRenderTarget fromD3D11Texture (void * texture , const QSize & pixelSize , int sampleCount = 1)
(从 6.6 起) QQuickRenderTarget fromD3D12Texture (void * texture , int resourceState , uint format , const QSize & pixelSize , int sampleCount = 1)
(从 6.4 起) QQuickRenderTarget fromMetalTexture (MTLTexture * texture , uint format , const QSize & pixelSize , int sampleCount = 1)
QQuickRenderTarget fromMetalTexture (MTLTexture * texture , const QSize & pixelSize , int sampleCount = 1)
(从 6.2 起) QQuickRenderTarget fromOpenGLRenderBuffer (uint renderbufferId , const QSize & pixelSize , int sampleCount = 1)
(从 6.4 起) QQuickRenderTarget fromOpenGLTexture (uint textureId , uint format , const QSize & pixelSize , int sampleCount = 1)
QQuickRenderTarget fromOpenGLTexture (uint textureId , const QSize & pixelSize , int sampleCount = 1)
(从 6.4 起) QQuickRenderTarget fromPaintDevice (QPaintDevice * device )
(从 6.6 起) QQuickRenderTarget fromRhiRenderTarget (QRhiRenderTarget * renderTarget )
(从 6.4 起) QQuickRenderTarget fromVulkanImage (VkImage image , VkImageLayout layout , VkFormat format , const QSize & pixelSize , int sampleCount = 1)
QQuickRenderTarget fromVulkanImage (VkImage image , VkImageLayout layout , const QSize & pixelSize , int sampleCount = 1)
bool operator!= (const QQuickRenderTarget & a , const QQuickRenderTarget & b )
bool operator== (const QQuickRenderTarget & a , const QQuickRenderTarget & b )

详细描述

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickGraphicsDevice .

成员函数文档编制

QQuickRenderTarget:: QQuickRenderTarget ()

Constructs a default QQuickRenderTarget that does not reference any native objects.

[noexcept] QQuickRenderTarget:: ~QQuickRenderTarget ()

析构函数。

[since 6.3] qreal QQuickRenderTarget:: devicePixelRatio () const

Returns the device pixel ratio for the render target. This is the ratio between 设备像素 and 设备无关像素 .

The default device pixel ratio is 1.0.

该函数在 Qt 6.3 引入。

另请参阅 setDevicePixelRatio ().

[static, since 6.4] QQuickRenderTarget QQuickRenderTarget:: fromD3D11Texture ( void * texture , uint format , const QSize & pixelSize , int sampleCount = 1)

返回新的 QQuickRenderTarget referencing a D3D11 texture object specified by texture .

format specifies the DXGI_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 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.

该函数在 Qt 6.4 引入。

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static] QQuickRenderTarget QQuickRenderTarget:: fromD3D11Texture ( void * texture , const QSize & pixelSize , int sampleCount = 1)

这是重载函数。

返回新的 QQuickRenderTarget referencing a D3D11 texture object specified by texture . The texture is assumed to have a format of DXGI_FORMAT_R8G8B8A8_UNORM.

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 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.

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static, since 6.6] QQuickRenderTarget QQuickRenderTarget:: fromD3D12Texture ( void * texture , int resourceState , uint format , const QSize & pixelSize , int sampleCount = 1)

返回新的 QQuickRenderTarget referencing a D3D12 texture object specified by texture .

resourceState must a valid bitmask with bits from D3D12_RESOURCE_STATES, specifying the resource's current state.

format specifies the DXGI_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 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.

该函数在 Qt 6.6 引入。

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static, since 6.4] QQuickRenderTarget QQuickRenderTarget:: fromMetalTexture ( MTLTexture * texture , uint format , const QSize & pixelSize , int sampleCount = 1)

返回新的 QQuickRenderTarget referencing a Metal texture object specified by texture .

format specifies the MTLPixelFormat 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 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.

该函数在 Qt 6.4 引入。

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static] QQuickRenderTarget QQuickRenderTarget:: fromMetalTexture ( MTLTexture * texture , const QSize & pixelSize , int sampleCount = 1)

这是重载函数。

返回新的 QQuickRenderTarget referencing a Metal texture object specified by texture . The texture is assumed to have a format of MTLPixelFormatRGBA8Unorm.

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 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.

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static, since 6.2] QQuickRenderTarget QQuickRenderTarget:: fromOpenGLRenderBuffer ( uint renderbufferId , const QSize & pixelSize , int sampleCount = 1)

返回新的 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.

注意: 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.

该函数在 Qt 6.2 引入。

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static, since 6.4] QQuickRenderTarget QQuickRenderTarget:: fromOpenGLTexture ( uint textureId , uint format , const QSize & pixelSize , int sampleCount = 1)

返回新的 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.

注意: 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.

该函数在 Qt 6.4 引入。

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static] QQuickRenderTarget QQuickRenderTarget:: fromOpenGLTexture ( uint textureId , const QSize & pixelSize , int sampleCount = 1)

这是重载函数。

返回新的 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.

注意: 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.

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static, since 6.4] QQuickRenderTarget QQuickRenderTarget:: fromPaintDevice ( QPaintDevice * device )

返回新的 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.

注意: The QQuickRenderTarget does not take ownship of device , it is the caller's responsibility to ensure the object exists as long as necessary.

该函数在 Qt 6.4 引入。

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static, since 6.6] QQuickRenderTarget QQuickRenderTarget:: fromRhiRenderTarget ( QRhiRenderTarget * renderTarget )

返回新的 QQuickRenderTarget referencing an existing renderTarget .

renderTarget will in most cases be a QRhiTextureRenderTarget , which allows directing the Qt Quick scene's rendering into a QRhiTexture .

注意: the resulting QQuickRenderTarget does not own renderTarget and 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.

该函数在 Qt 6.6 引入。

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static, since 6.4] QQuickRenderTarget QQuickRenderTarget:: fromVulkanImage ( VkImage image , VkImageLayout layout , VkFormat format , const QSize & pixelSize , int sampleCount = 1)

返回新的 QQuickRenderTarget referencing a Vulkan image object specified by image . The current layout of the image must be provided as well.

format specifies the VkFormat of the image. Only image 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 image 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 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.

该函数在 Qt 6.4 引入。

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

[static] QQuickRenderTarget QQuickRenderTarget:: fromVulkanImage ( VkImage image , VkImageLayout layout , const QSize & pixelSize , int sampleCount = 1)

这是重载函数。

返回新的 QQuickRenderTarget referencing a Vulkan image object specified by image . The image is assumed to have a format of VK_FORMAT_R8G8B8A8_UNORM.

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 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.

另请参阅 QQuickWindow::setRenderTarget () 和 QQuickRenderControl .

bool QQuickRenderTarget:: isNull () const

返回 true,若此 QQuickRenderTarget is default constructed, referencing no native objects.

[since 6.4] bool QQuickRenderTarget:: mirrorVertically () const

Returns Returns whether the render target is mirrored vertically.

默认值为 false .

该函数在 Qt 6.4 引入。

另请参阅 setMirrorVertically ().

[since 6.3] void QQuickRenderTarget:: setDevicePixelRatio ( qreal ratio )

Sets the device pixel ratio for this render target to ratio . This is the ratio between 设备像素 and 设备无关像素 .

Note that the specified device pixel ratio value will be ignored if QQuickRenderControl::renderWindow () is re-implemented to return a valid QWindow .

该函数在 Qt 6.3 引入。

另请参阅 devicePixelRatio ().

[since 6.4] void QQuickRenderTarget:: setMirrorVertically ( bool enable )

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.

注意: This function should not be used when using the software backend.

该函数在 Qt 6.4 引入。

另请参阅 mirrorVertically ().

相关非成员

[noexcept] bool operator!= (const QQuickRenderTarget & a , const QQuickRenderTarget & b )

返回 true 若 a and b refer to a different set of native objects, or the associated data (size, sample count) does not match.

[noexcept] bool operator== (const QQuickRenderTarget & a , const QQuickRenderTarget & b )

返回 true 若 a and b refer to the same set of native objects and have matching associated data (size, sample count).