QSGMaterialShader::GraphicsPipelineState Struct
struct QSGMaterialShader::GraphicsPipelineState描述了材质希望应用于当前活动图形管道状态的状态变更。更多...
公共类型
| enum | BlendFactor { Zero, One, SrcColor, OneMinusSrcColor, DstColor, …, OneMinusSrc1Alpha } |
(since 6.8) enum class | BlendOp { Add, Subtract, ReverseSubtract, Min, Max } |
| flags | ColorMask |
| enum | ColorMaskComponent { R, G, B, A } |
| enum | CullMode { CullNone, CullFront, CullBack } |
(since 6.4) enum | PolygonMode { Fill, Line } |
公共变量
| QColor | blendConstant |
| bool | blendEnable |
| QSGMaterialShader::GraphicsPipelineState::ColorMask | colorWrite |
| QSGMaterialShader::GraphicsPipelineState::CullMode | cullMode |
(since 6.5) QSGMaterialShader::GraphicsPipelineState::BlendFactor | dstAlpha |
| QSGMaterialShader::GraphicsPipelineState::BlendFactor | dstColor |
(since 6.8) QSGMaterialShader::GraphicsPipelineState::BlendOp | opAlpha |
(since 6.8) QSGMaterialShader::GraphicsPipelineState::BlendOp | opColor |
(since 6.4) QSGMaterialShader::GraphicsPipelineState::PolygonMode | polygonMode |
(since 6.5) bool | separateBlendFactors |
(since 6.5) QSGMaterialShader::GraphicsPipelineState::BlendFactor | srcAlpha |
| QSGMaterialShader::GraphicsPipelineState::BlendFactor | srcColor |
详细说明
与QSGMaterialShader 不同,QSGMaterialShader 无法直接通过底层图形API发出状态更改命令。这主要是因为“可单独更改的状态”这一概念已被视为过时,且不受现代图形API的支持。
因此,应由QSGMaterialShader 提供包含受支持状态集合的数据结构,材质可在其updatePipelineState()实现中(若存在该方法)对这些状态进行修改。随后,场景图将在内部将这些更改应用到当前活动的图形管道状态,并在适当的时候将其回滚。
当调用updateGraphicsPipelineState() 时,该结构体的所有成员均被设置为有效值,以反映渲染器的当前状态。不更改任何值(或未重写该函数)表示材质接受默认值(但这些默认值是动态的,例如取决于QSGMaterial 标志)。
成员类型文档
enum GraphicsPipelineState::BlendFactor
| 常数 | 值 |
|---|---|
QSGMaterialShader::GraphicsPipelineState::Zero | 0 |
QSGMaterialShader::GraphicsPipelineState::One | 1 |
QSGMaterialShader::GraphicsPipelineState::SrcColor | 2 |
QSGMaterialShader::GraphicsPipelineState::OneMinusSrcColor | 3 |
QSGMaterialShader::GraphicsPipelineState::DstColor | 4 |
QSGMaterialShader::GraphicsPipelineState::OneMinusDstColor | 5 |
QSGMaterialShader::GraphicsPipelineState::SrcAlpha | 6 |
QSGMaterialShader::GraphicsPipelineState::OneMinusSrcAlpha | 7 |
QSGMaterialShader::GraphicsPipelineState::DstAlpha | 8 |
QSGMaterialShader::GraphicsPipelineState::OneMinusDstAlpha | 9 |
QSGMaterialShader::GraphicsPipelineState::ConstantColor | 10 |
QSGMaterialShader::GraphicsPipelineState::OneMinusConstantColor | 11 |
QSGMaterialShader::GraphicsPipelineState::ConstantAlpha | 12 |
QSGMaterialShader::GraphicsPipelineState::OneMinusConstantAlpha | 13 |
QSGMaterialShader::GraphicsPipelineState::SrcAlphaSaturate | 14 |
QSGMaterialShader::GraphicsPipelineState::Src1Color | 15 |
QSGMaterialShader::GraphicsPipelineState::OneMinusSrc1Color | 16 |
QSGMaterialShader::GraphicsPipelineState::Src1Alpha | 17 |
QSGMaterialShader::GraphicsPipelineState::OneMinusSrc1Alpha | 18 |
[since 6.8] enum class GraphicsPipelineState::BlendOp
| 常数 | 值 |
|---|---|
QSGMaterialShader::GraphicsPipelineState::BlendOp::Add | 0 |
QSGMaterialShader::GraphicsPipelineState::BlendOp::Subtract | 1 |
QSGMaterialShader::GraphicsPipelineState::BlendOp::ReverseSubtract | 2 |
QSGMaterialShader::GraphicsPipelineState::BlendOp::Min | 3 |
QSGMaterialShader::GraphicsPipelineState::BlendOp::Max | 4 |
该枚举类型在 Qt 6.8 中引入。
enum GraphicsPipelineState::ColorMaskComponent
flags GraphicsPipelineState::ColorMask
| 常数 | 值 |
|---|---|
QSGMaterialShader::GraphicsPipelineState::R | 1 << 0 |
QSGMaterialShader::GraphicsPipelineState::G | 1 << 1 |
QSGMaterialShader::GraphicsPipelineState::B | 1 << 2 |
QSGMaterialShader::GraphicsPipelineState::A | 1 << 3 |
ColorMask 类型是QFlags<ColorMaskComponent> 的 typedef。它存储了 ColorMaskComponent 值的按“或”(OR)运算组合。
enum GraphicsPipelineState::CullMode
| 常数 | 值 |
|---|---|
QSGMaterialShader::GraphicsPipelineState::CullNone | 0 |
QSGMaterialShader::GraphicsPipelineState::CullFront | 1 |
QSGMaterialShader::GraphicsPipelineState::CullBack | 2 |
[since 6.4] enum GraphicsPipelineState::PolygonMode
指定多边形光栅化模式
多边形模式(Metal 中的“三角形填充模式”,D3D 中的“填充模式”)指定了渲染多边形时使用的填充模式。多边形可以以实心(填充)形式绘制,也可以以线框(线条)形式绘制。
警告:OpenGL ES 不支持Line 多边形模式。无论设置何种多边形模式,OpenGL ES 都会将所有多边形渲染为实心。使用Line 会导致您的应用程序无法跨平台运行。
| 常量 | 值 | 描述 |
|---|---|---|
QSGMaterialShader::GraphicsPipelineState::Fill | 0 | 多边形的内部被填充(默认) |
QSGMaterialShader::GraphicsPipelineState::Line | 1 | 多边形的边界边被绘制为线段。 |
该枚举类型在 Qt 6.4 中引入。
成员变量文档
QColor GraphicsPipelineState::blendConstant
当混合因子设置为使用常量值时,该常量即为适用值。
bool GraphicsPipelineState::blendEnable
启用混合效果。
注意:修改 此标志应谨慎操作,最好避免。相反,材质应始终使用 QSGMaterial::Blend 标志来表明其希望使用混合效果。对于未声明 QSGMaterial::Blend 的材质,将此值从 false 改为 true 可能会导致意想不到的视觉效果。
QSGMaterialShader::GraphicsPipelineState::ColorMask GraphicsPipelineState::colorWrite
颜色写入掩码。
QSGMaterialShader::GraphicsPipelineState::CullMode GraphicsPipelineState::cullMode
筛选模式。
[since 6.5] QSGMaterialShader::GraphicsPipelineState::BlendFactor GraphicsPipelineState::dstAlpha
目标阿尔法混合因子。
仅当separateBlendFactors 设置为true时生效。
该变量自 Qt 6.5 起引入。
QSGMaterialShader::GraphicsPipelineState::BlendFactor GraphicsPipelineState::dstColor
目标混合因子,根据separateBlendFactors 确定,可以是 RGB 或 RGBA。
[since 6.8] QSGMaterialShader::GraphicsPipelineState::BlendOp GraphicsPipelineState::opAlpha
Alpha混合操作。
该变量在 Qt 6.8 中引入。
[since 6.8] QSGMaterialShader::GraphicsPipelineState::BlendOp GraphicsPipelineState::opColor
RGB 混合操作。
该变量在 Qt 6.8 中引入。
[since 6.4] QSGMaterialShader::GraphicsPipelineState::PolygonMode GraphicsPipelineState::polygonMode
多边形栅格化模式。
该变量自 Qt 6.4 起引入。
[since 6.5] bool GraphicsPipelineState::separateBlendFactors
表示 alpha 混合因子是单独指定的。
默认值为 False,这意味着 RGB 和 alpha 混合因子均由srcColor 和dstColor 定义。当设置为 true 时,alpha 混合因子将改为从srcAlpha 和dstAlpha 获取,而srcColor 和dstColor 仅适用于 RGB。
该变量在 Qt 6.5 中引入。
[since 6.5] QSGMaterialShader::GraphicsPipelineState::BlendFactor GraphicsPipelineState::srcAlpha
源α混合因子。
仅当separateBlendFactors 设置为true时生效。
该变量在 Qt 6.5 中引入。
QSGMaterialShader::GraphicsPipelineState::BlendFactor GraphicsPipelineState::srcColor
源混合因子,根据separateBlendFactors ,可为RGB或RGBA。
© 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.