6#include <QtQuick/QSGMaterial>
76 Q_ASSERT(oldMaterial ==
nullptr || newMaterial->
type() == oldMaterial->
type());
83 if (
state.isMatrixDirty()) {
85 memcpy(
buf->data(),
m.constData(), 64);
91 memcpy(
buf->data() + 64, animPosAndData, 28);
94 if (
state.isOpacityDirty()) {
95 const float opacity =
state.opacity();
96 memcpy(
buf->data() + 92, &opacity, 4);
112 Q_ASSERT(oldMaterial ==
nullptr || newMaterial->
type() == oldMaterial->
type());
134 (2+2) *
sizeof(
float),
140 , m_geometryDirty(true)
141 , m_sheetSize(
QSize(64, 64))
154 setGeometry(m_geometry);
155 setMaterial(m_material);
156 setFlag(OwnsGeometry,
true);
157 setFlag(OwnsMaterial,
true);
163 m_geometryDirty =
true;
164 markDirty(DirtyMaterial);
170 markDirty(DirtyMaterial);
175 if (m_sourceA !=
source) {
179 markDirty(DirtyMaterial);
185 if (m_sourceB !=
source) {
189 markDirty(DirtyMaterial);
195 if (m_spriteSize !=
size) {
197 m_material->
animW =
static_cast<float>(
size.width()) / m_sheetSize.
width();
198 m_material->
animH =
static_cast<float>(
size.height()) / m_sheetSize.
height();
199 markDirty(DirtyMaterial);
206 if (m_sheetSize !=
size) {
210 m_material->
animX1 =
static_cast<float>(m_sourceA.
x()) / m_sheetSize.
width();
211 m_material->
animY1 =
static_cast<float>(m_sourceA.
y()) / m_sheetSize.
height();
212 m_material->
animX2 =
static_cast<float>(m_sourceB.
x()) / m_sheetSize.
width();
213 m_material->
animY2 =
static_cast<float>(m_sourceB.
y()) / m_sheetSize.
height();
214 m_material->
animW =
static_cast<float>(m_spriteSize.
width()) / m_sheetSize.
width();
215 m_material->
animH =
static_cast<float>(m_spriteSize.
height()) / m_sheetSize.
height();
216 markDirty(DirtyMaterial);
222 if (m_size !=
size) {
224 m_geometryDirty =
true;
231 markDirty(DirtyMaterial);
236 if (m_geometryDirty) {
238 m_geometryDirty =
false;
242void QSGDefaultSpriteNode::updateGeometry()
274 markDirty(DirtyGeometry);
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
\inmodule QtCore\reentrant
constexpr QPointF bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
constexpr QPointF topRight() const noexcept
Returns the position of the rectangle's top-right corner.
void setTexture(QSGTexture *texture) override
void setSheetSize(const QSize &size) override
void setSourceA(const QPoint &source) override
void setSize(const QSizeF &size) override
void setSpriteSize(const QSize &size) override
void setSourceB(const QPoint &source) override
void setTime(float time) override
void setFiltering(QSGTexture::Filtering filtering) override
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
void setDrawingMode(unsigned int mode)
Sets the mode to be used for drawing this geometry.
void * vertexData()
Returns a pointer to the raw vertex data of this geometry object.
quint16 * indexDataAsUShort()
Convenience function to access the index data as a mutable array of 16-bit unsigned integers.
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.
virtual QSGMaterialType * type() const =0
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
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...
virtual void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
Call this function to enqueue image upload operations to resourceUpdates, in case there are any pendi...
virtual QRectF normalizedTextureSubRect() const
Returns the rectangle inside textureSize() that this texture represents in normalized coordinates.
void setFiltering(Filtering filter)
Sets the sampling mode to filter.
Filtering
Specifies how sampling of texels should filter when texture coordinates are not pixel aligned.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
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...
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
SpriteMaterialRhiShader()
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const void * indices
GLsizei GLsizei GLchar * source
static QSGGeometry::Attribute Sprite_Attributes[]
static QSGGeometry::AttributeSet Sprite_AttributeSet
#define QStringLiteral(str)
The QSGGeometry::AttributeSet describes how the vertices in a QSGGeometry are built up.
The QSGGeometry::Attribute describes a single vertex attribute in a QSGGeometry.
static Attribute create(int pos, int tupleSize, int primitiveType, bool isPosition=false)
Creates a new QSGGeometry::Attribute for attribute register pos with tupleSize.
The QSGMaterialType class is used as a unique type token in combination with QSGMaterial.