Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsgvertexcolormaterial.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
7
9{
10public:
12
13 bool updateUniformData(RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
14};
15
17{
18 setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/vertexcolor.vert.qsb"));
19 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/vertexcolor.frag.qsb"));
20}
21
23 QSGMaterial * /*newEffect*/,
24 QSGMaterial * /*oldEffect*/)
25{
26 bool changed = false;
27 QByteArray *buf = state.uniformData();
28
29 if (state.isMatrixDirty()) {
30 const QMatrix4x4 m = state.combinedMatrix();
31 memcpy(buf->data(), m.constData(), 64);
32 changed = true;
33 }
34
35 if (state.isOpacityDirty()) {
36 const float opacity = state.opacity();
37 memcpy(buf->data() + 64, &opacity, 4);
38 changed = true;
39 }
40
41 return changed;
42}
43
44
79{
80 setFlag(Blending, true);
81}
82
83
93int QSGVertexColorMaterial::compare(const QSGMaterial * /* other */) const
94{
95 return 0;
96}
97
103{
104 static QSGMaterialType type;
105 return &type;
106}
107
108
109
115{
116 Q_UNUSED(renderMode);
118}
119
\inmodule QtCore
Definition qbytearray.h:57
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and ...
The QSGMaterialShader class represents a graphics API independent shader program.
void setShaderFileName(Stage stage, const QString &filename)
Sets the filename for the shader for the specified stage.
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
void setFlag(Flags flags, bool on=true)
Sets the flags flags on this material if on is true; otherwise clears the attribute.
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
bool updateUniformData(RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
int compare(const QSGMaterial *other) const override
int QSGVertexColorMaterial::compare() const
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
QSGMaterialType * type() const override
QSGVertexColorMaterial()
Creates a new vertex color material.
else opt state
[0]
Combined button and popup list for selecting options.
const GLfloat * m
GLenum GLuint GLenum GLsizei const GLchar * buf
#define QStringLiteral(str)
#define Q_UNUSED(x)
The QSGMaterialType class is used as a unique type token in combination with QSGMaterial.