QParameter Class
(Qt3DRender::QParameter)Provides storage for a name and value pair. This maps to a shader uniform. 更多...
头文件: | #include <Qt3DRender/QParameter> |
qmake: | QT += 3drender |
Instantiated By: | Parameter |
基类: | Qt3DCore::QNode |
属性
- 3 个属性继承自 Qt3DCore::QNode
- 1 个属性继承自 QObject
公有函数
QParameter(Qt3DCore::QNode *parent = nullptr) | |
QParameter(const QString &name, const QVariant &value, Qt3DCore::QNode *parent = nullptr) | |
QParameter(const QString &name, QAbstractTexture *texture, Qt3DCore::QNode *parent = nullptr) | |
QString | name() const |
QVariant | value() const |
- 11 个公有函数继承自 Qt3DCore::QNode
- 32 个公有函数继承自 QObject
公有槽函数
- 3 个公有槽函数继承自 Qt3DCore::QNode
- 1 个公有槽函数继承自 QObject
信号
void | nameChanged(const QString &name) |
void | valueChanged(const QVariant &value) |
- 4 个信号继承自 Qt3DCore::QNode
- 2 个信号继承自 QObject
受保护的函数
QParameter(QParameterPrivate &dd, Qt3DCore::QNode *parent = nullptr) |
- 2 个受保护的函数继承自 Qt3DCore::QNode
- 9 个受保护的函数继承自 QObject
其他继承的成员
详细描述
Provides storage for a name and value pair. This maps to a shader uniform.
A QParameter can be referenced by a QRenderPass, QTechnique, QEffect, QMaterial, QTechniqueFilter, QRenderPassFilter. At runtime, depending on which shader is selected for a given step of the rendering, the value contained in a QParameter will be converted and uploaded if the shader contains a uniform with a name matching that of the QParameter.
QParameter *param = new QParameter(); param->setName(QStringLiteral("diffuseColor")); param->setValue(QColor::fromRgbF(0.0f, 0.0f, 1.0f, 1.0f)); // Alternatively you can create and set a QParameter this way QParameter *param2 = new QParameter(QStringLiteral("diffuseColor"), QColor::fromRgbF(0.0f, 0.0f, 1.0f, 1.0f)); // Such QParameters will work with the following GLSL uniform shader declarations // uniform vec4 diffuseColor; // uniform vec3 diffuseColor; // uniform vec2 diffuseColor; // uniform float diffuseColor;
Note: some care must be taken to ensure the value wrapped by a QParameter can actually be converted to what the real uniform expect. Giving a value stored as an int where the actual shader uniform is of type float could result in undefined behaviors.
Note: when the targeted uniform is an array, the name should be the name of the uniform with [0] appended to it.
QParameter *param = new QParameter(); QVariantList values = QVariantList() << 0.0f << 1.0f << 2.0f << 3.0f << 4.0f << 883.0f << 1340.0f << 1584.0f; param->setName(QStringLiteral("diffuseValues[0]")); param->setValue(values); // Matching GLSL shader uniform declaration // uniform float diffuseValues[8];
When it comes to texture support, the QParameter value should be set to the appropriate QAbstractTexture subclass that matches the sampler type of the shader uniform.
QTexture2D *texture = new QTexture2D(); ... QParameter *param = new QParameter(); param->setName(QStringLiteral("diffuseTexture")); param->setValue(QVariant::fromValue(texture)); // Works with the following GLSL uniform shader declaration // uniform sampler2D diffuseTexture
参见 QAbstractTexture.
属性
name : QString
Specifies the name of the parameter
访问函数:
QString | name() const |
void | setName(const QString &name) |
Notifier signal:
void | nameChanged(const QString &name) |
value : QVariant
Specifies the value of the parameter
访问函数:
QVariant | value() const |
void | setValue(const QVariant &dv) |
Notifier signal:
void | valueChanged(const QVariant &value) |
成员函数
QParameter::QParameter(Qt3DCore::QNode *parent = nullptr)
Constructs a new QParameter with the specified parent.
QParameter::QParameter(const QString &name, const QVariant &value, Qt3DCore::QNode *parent = nullptr)
Default constructs an instance of QParameter.
QParameter::QParameter(const QString &name, QAbstractTexture *texture, Qt3DCore::QNode *parent = nullptr)
Default constructs an instance of QParameter.
[protected]
QParameter::QParameter(QParameterPrivate &dd, Qt3DCore::QNode *parent = nullptr)
Copy constructor.