Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickshapecurvenode.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 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
6
8
9namespace {
10}
11
13{
14 setFlag(OwnsGeometry, true);
15 setGeometry(new QSGGeometry(attributes(), 0, 0));
16
17 updateMaterial();
18}
19
20void QQuickShapeCurveNode::updateMaterial()
21{
22 m_material.reset(new QQuickShapeCurveMaterial(this));
23 setMaterial(m_material.data());
24}
25
27{
29 if (g->indexType() != QSGGeometry::UnsignedIntType) {
30 g = new QSGGeometry(attributes(),
31 m_uncookedVertexes.size(),
32 m_uncookedIndexes.size(),
35 } else {
36 g->allocate(m_uncookedVertexes.size(), m_uncookedIndexes.size());
37 }
38
39 g->setDrawingMode(QSGGeometry::DrawTriangles);
40 memcpy(g->vertexData(),
41 m_uncookedVertexes.constData(),
42 g->vertexCount() * g->sizeOfVertex());
43 memcpy(g->indexData(),
44 m_uncookedIndexes.constData(),
45 g->indexCount() * g->sizeOfIndex());
46
47 m_uncookedIndexes.clear();
48 m_uncookedVertexes.clear();
49}
50
51const QSGGeometry::AttributeSet &QQuickShapeCurveNode::attributes()
52{
53 static QSGGeometry::Attribute data[] = {
58 };
59 static QSGGeometry::AttributeSet attrs = { 4, sizeof(CurveNodeVertex), data };
60 return attrs;
61}
62
const QSGGeometry * geometry() const
Returns this node's geometry.
Definition qsgnode.h:160
void setGeometry(QSGGeometry *geometry)
Sets the geometry of this node to geometry.
Definition qsgnode.cpp:762
void setMaterial(QSGMaterial *material)
Sets the material of this geometry node to material.
Definition qsgnode.cpp:925
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
Definition qsggeometry.h:15
@ OwnsGeometry
Definition qsgnode.h:57
void setFlag(Flag, bool=true)
Sets the flag f on this node if enabled is true; otherwise clears the flag.
Definition qsgnode.cpp:584
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
Combined button and popup list for selecting options.
static struct AttrInfo attrs[]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLboolean GLboolean g
The QSGGeometry::AttributeSet describes how the vertices in a QSGGeometry are built up.
Definition qsggeometry.h:73
The QSGGeometry::Attribute describes a single vertex attribute in a QSGGeometry.
Definition qsggeometry.h:58
static Attribute createWithAttributeType(int pos, int tupleSize, int primitiveType, AttributeType attributeType)
Creates a new QSGGeometry::Attribute for attribute register pos with tupleSize.