QRhiRenderTarget Class
表示屏幕内(交换链)或屏幕外(纹理)的渲染目标。更多...
| 头文件: | #include <rhi/qrhi.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS GuiPrivate) target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate) |
| qmake: | QT += gui-private |
| 自: | Qt 6.6 |
| 继承自: | QRhiResource |
| 继承自: |
公共函数
| virtual float | devicePixelRatio() const = 0 |
| virtual QSize | pixelSize() const = 0 |
| QRhiRenderPassDescriptor * | renderPassDescriptor() const |
| virtual int | sampleCount() const = 0 |
| void | setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) |
详细说明
应用程序不会直接创建该类的实例。相反,API 客户端可通过 `newTextureRenderTarget()` 方法实例化其子类 `QRhiTextureRenderTarget `。另一个子类是 `QRhiSwapChainRenderTarget`,这是调用 `currentFrameRenderTarget()` 时 `QRhiSwapChain ` 返回的类型。
注意:这是一个 兼容性保证有限的 RHI API,详情请参阅QRhi 。
另请参阅 QRhiSwapChainRenderTarget 和QRhiTextureRenderTarget 。
成员函数文档
[pure virtual] float QRhiRenderTarget::devicePixelRatio() const
返回设备像素比。对于QRhiTextureRenderTarget ,该值始终为1。对于从QRhiSwapChain 获取的目标,该值反映了目标QWindow 的device pixel ratio 。
[pure virtual] QSize QRhiRenderTarget::pixelSize() const
返回以像素为单位的大小。
仅在成功调用 create() 之后才有效。在此之前,返回结果为默认构造的QSize 。
对于 `QRhiTextureRenderTarget `,返回的大小是 `create()` 调用时关联附件的大小,实际上即第一个颜色附件的大小;若无颜色附件,则为深度/模板缓冲区的大小。 如果关联的纹理或渲染缓冲区随后被调整大小并重建,则 pixelSize() 会隐式调用 create() 以重建底层数据结构。此隐式检查与QRhiCommandBuffer::beginPass() 的操作类似,可确保返回的大小始终是最新的。
QRhiRenderPassDescriptor *QRhiRenderTarget::renderPassDescriptor() const
返回关联的QRhiRenderPassDescriptor 。
另请参阅 setRenderPassDescriptor()。
[pure virtual] int QRhiRenderTarget::sampleCount() const
返回采样数;如果多采样抗锯齿对该渲染目标不适用,则返回 1。
void QRhiRenderTarget::setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
设置QRhiRenderPassDescriptor desc ,以便与该渲染目标配合使用。
另请参阅 renderPassDescriptor()。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.