AddDefine QML Type
| Import Statement: | import QtQuick3D |
| Since: | Qt 6.11 |
| Inherits: |
属性
详细说明
AddDefine 类型用于在RenderPass 的着色器编译过程中注入#define 。这允许您根据当前执行的处理阶段,在编译时对着色器行为进行分支控制。
在着色器代码中,该定义可与标准预处理器指令#ifdef /#if 配合使用:
#ifdef CUSTOM_PASS_MODE
// code compiled only when this define is present
#endifRenderPass {
commands: [
ColorAttachment { name: "color0"; target: colorTexture },
AddDefine { name: "CUSTOM_PASS_MODE" },
AddDefine { name: "OUTPUT_VERSION"; value: 2 }
]
}属性文档
name : string
要定义的预处理器宏的名称。该名称将成为着色器代码中进行#ifdef 或#if 检查时使用的标识符。
value : int
分配给预处理器宏的整数值。默认值为1 。当该值不为零时,#if NAME 在着色器中将求值为true 。
© 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.