Qt3DExtras::QForwardRenderer Class

class Qt3DExtras::QForwardRenderer

QForwardRenderer 提供了前向渲染器的默认FrameGraph实现。更多

Header: #include <QForwardRenderer>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3dextras)
target_link_libraries(mytarget PRIVATE Qt6::3dextras)
qmake: QT += 3dextras
在 QML 中: ForwardRenderer
继承: Qt3DRender::QTechniqueFilter
状态:已废弃

属性

公共功能

Qt3DRender::QClearBuffers::BufferType buffersToClear() const
Qt3DCore::QEntity *camera() const
QColor clearColor() const
QSize externalRenderTargetSize() const
float gamma() const
bool isFrustumCullingEnabled() const
bool showDebugOverlay() const
QObject *surface() const
QRectF viewportRect() const

公共插槽

void setBuffersToClear(Qt3DRender::QClearBuffers::BufferType)
void setCamera(Qt3DCore::QEntity *camera)
void setClearColor(const QColor &clearColor)
void setExternalRenderTargetSize(const QSize &size)
void setFrustumCullingEnabled(bool enabled)
void setGamma(float gamma)
void setShowDebugOverlay(bool showDebugOverlay)
void setSurface(QObject *surface)
void setViewportRect(const QRectF &viewportRect)

信号

void buffersToClearChanged(Qt3DRender::QClearBuffers::BufferType)
void cameraChanged(Qt3DCore::QEntity *camera)
void clearColorChanged(const QColor &clearColor)
void externalRenderTargetSizeChanged(const QSize &size)
void frustumCullingEnabledChanged(bool enabled)
void gammaChanged(float gamma)
void showDebugOverlayChanged(bool showDebugOverlay)
void surfaceChanged(QObject *surface)
void viewportRectChanged(const QRectF &viewportRect)

详细说明

前向渲染是 OpenGL 传统上使用的渲染方式。它每次直接向后缓冲区渲染一个对象,并在渲染过程中为每个对象着色。

QForwardRenderer 是一个单叶FrameGraph树,其中包含一个Qt3DRender::QViewport 、一个Qt3DRender::QCameraSelector 和一个Qt3DRender::QClearBuffers 。QForwardRenderer 有一个默认的需求过滤键,其名称为 "renderingStyle",值为 "forward"。如果你需要过滤出你的技术,你应该根据该过滤键来做。

默认情况下,视口会占据整个屏幕,透明色为白色。此外,还启用了渲染剔除功能。

属性文档

buffersToClear : Qt3DRender::QClearBuffers::BufferType

保存要清除的当前缓冲区。默认值为 ColorDepthBuffer

访问功能:

Qt3DRender::QClearBuffers::BufferType buffersToClear() const
void setBuffersToClear(Qt3DRender::QClearBuffers::BufferType)

通知信号:

void buffersToClearChanged(Qt3DRender::QClearBuffers::BufferType)

camera : Qt3DCore::QEntity*

保存当前用于渲染场景的相机实体。

注: 相机是一个以 QCameraLens 为组件的 QEntity。

访问功能:

Qt3DCore::QEntity *camera() const
void setCamera(Qt3DCore::QEntity *camera)

通知信号

void cameraChanged(Qt3DCore::QEntity *camera)

clearColor : QColor

保存场景的当前净色。在渲染前,帧缓冲区会被初始化为该颜色。

访问功能

QColor clearColor() const
void setClearColor(const QColor &clearColor)

通知信号

void clearColorChanged(const QColor &clearColor)

externalRenderTargetSize : QSize

包含外部呈现目标的大小。当渲染不以窗口表面为目标(如surface 中所设置)时,外部渲染目标就与之相关。

访问功能:

QSize externalRenderTargetSize() const
void setExternalRenderTargetSize(const QSize &size)

通知信号:

void externalRenderTargetSizeChanged(const QSize &size)

frustumCulling : bool

指示渲染器是否在场景中应用挫边剔除。

访问功能:

bool isFrustumCullingEnabled() const
void setFrustumCullingEnabled(bool enabled)

通知信号

void frustumCullingEnabledChanged(bool enabled)

gamma : float

保存渲染器应用于场景的伽玛值。

访问功能:

float gamma() const
void setGamma(float gamma)

通知信号:

void gammaChanged(float gamma)

showDebugOverlay : bool

如果为 "true",则会在场景上渲染调试覆盖层。它将显示运行时渲染状态的详细信息,允许用户打开或关闭日志记录等。

访问功能:

bool showDebugOverlay() const
void setShowDebugOverlay(bool showDebugOverlay)

Notifier 信号:

void showDebugOverlayChanged(bool showDebugOverlay)

surface : QObject*

保存当前的渲染表面。

访问功能:

QObject *surface() const
void setSurface(QObject *surface)

通知信号:

void surfaceChanged(QObject *surface)

viewportRect : QRectF

保存当前规范化视口矩形。

访问功能:

QRectF viewportRect() const
void setViewportRect(const QRectF &viewportRect)

通知信号:

void viewportRectChanged(const QRectF &viewportRect)

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