Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 *newMaterial, QSGMaterial *oldMaterial) override;
14};
15
17{
18 setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/vertexcolor.vert.qsb"), viewCount);
19 setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/vertexcolor.frag.qsb"), viewCount);
20}
21
23{
24 bool changed = false;
25 QByteArray *buf = state.uniformData();
26 const int shaderMatrixCount = newMaterial->viewCount();
27 const int matrixCount = qMin(state.projectionMatrixCount(), shaderMatrixCount);
28
29 for (int viewIndex = 0; viewIndex < matrixCount; ++viewIndex) {
30 if (state.isMatrixDirty()) {
31 const QMatrix4x4 m = state.combinedMatrix(viewIndex);
32 memcpy(buf->data() + 64 * viewIndex, m.constData(), 64);
33 changed = true;
34 }
35 }
36
37 if (state.isOpacityDirty()) {
38 const float opacity = state.opacity();
39 memcpy(buf->data() + 64 * shaderMatrixCount, &opacity, 4);
40 changed = true;
41 }
42
43 return changed;
44}
45
46
84
85
95int QSGVertexColorMaterial::compare(const QSGMaterial * /* other */) const
96{
97 return 0;
98}
99
105{
106 static QSGMaterialType type;
107 return &type;
108}
109
110
111
121
\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
int viewCount() const
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 *newMaterial, QSGMaterial *oldMaterial) 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.
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
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.