Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3dtextureproviderextension.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5#include <QtQuick3D/private/qquick3dobject_p.h>
7
9
10/*!
11 \class QQuick3DTextureProviderExtension
12 \inmodule QtQuick3D
13 \since 6.11
14
15 \brief Abstract class for implementing user side texture provider extensions.
16
17 This is the front-end side of a texture provider extension. The back-end side is implemented
18 in \l QSSGRenderExtension. The QQuick3DTextureProviderExtension is a specialization of the
19 QQuick3DRenderExtension class that is used to create a custom texture provider extension that can
20 both provide additional metadata about what type of texture will be provided and also automatically
21 register the extension with the QtQuick3D scene graph. This means it is unecessary to manually add
22 the extension to the list of extensions to be used with a \l View3D, and just using the textureProvider
23 property of the Texture component is enough to trigger the extension code to be run when necessary.
24
25 The QQuick3DTextureProviderExtension class is an abstract class that should be subclassed and
26 exposed to QML. The subclass should implement the \l QQuick3DRenderExtension::updateSpatialNode()
27 function and return a QSSGRenderExtension instance that contains the code that should be run.
28
29 \sa QSSGRenderExtension
30*/
31
32/*!
33 \qmltype TextureProviderExtension
34 \nativetype QQuick3DTextureProviderExtension
35 \inqmlmodule QtQuick3D
36 \inherits RenderExtension
37 \since 6.11
38 \brief An uncreatable abstract base type for texture provider extensions.
39
40 \sa QQuick3DTextureProviderExtension, QSSGRenderExtension
41*/
42
43/*!
44 \qmlproperty enumeration TextureProviderExtension::samplerHint
45
46 This property contains a hint about the type of texture that will be provided by the extension.
47 This is necessary because the texture data will not be provided until it is necessary, but materials
48 that use the Texture component need to know what type of sampler to provide. This property should
49 be set to one of the following values:
50
51 \value TextureProviderExtension.Sampler2D The texture will be a 2D texture.
52 \value TextureProviderExtension.Sampler2DArray The texture will be an array texture.
53 \value TextureProviderExtension.Sampler3D The texture will be a 3D texture.
54 \value TextureProviderExtension.SamplerCube The texture will be a cube map texture.
55 \value TextureProviderExtension.SamplerCubeArray The texture will be an array of cube map textures.
56 \value TextureProviderExtension.SamplerBuffer The texture will be a buffer texture.
57
58 The default value is \c TextureProviderExtension.Sampler2D.
59
60 \note This property is only used when using CustomMaterials.
61*/
62
63
64QQuick3DTextureProviderExtensionPrivate::QQuick3DTextureProviderExtensionPrivate()
65 : QQuick3DObjectPrivate(QQuick3DObjectPrivate::Type::TextureProvider)
66{
67
68}
69
70
71QQuick3DTextureProviderExtension::QQuick3DTextureProviderExtension(QQuick3DObject *parent)
72 : QQuick3DRenderExtension(*new QQuick3DTextureProviderExtensionPrivate(), parent)
73{
74
75}
76
77QQuick3DTextureProviderExtension::~QQuick3DTextureProviderExtension()
78{
79
80}
81
82/*!
83 \fn QSSGRenderGraphObject *QQuick3DTextureProviderExtension::updateSpatialNode(QSSGRenderGraphObject *node)
84
85 This function is called during the synchronization of the QtQuick3D scene graph when an item is
86 created or when an update is requested, usually as a result of a change in the item's properties.
87 The function should return a QSSGRenderTextureProviderExtension instance that contains the code that should be
88 run during QtQuick3D's rendering pipeline execution.
89
90 The \a node parameter is the previous QSSGRenderTextureProviderExtension instance that was returned from this
91 function, or null if this is the first time the function is called. The function can return the
92 same instance, a different instance, or null. If the function returns null, the extension will
93 be removed from the rendering pipeline.
94
95 \note The QSSGRenderTextureProviderExtension instance is a resource object and will be owned by the QtQuick3D
96 scene graph. If a different instance, or null, is returned, the previous instance will be
97 queued for deletion by the renderer.
98
99 \sa QSSGRenderTextureProviderExtension
100*/
101
102QSSGRenderGraphObject *QQuick3DTextureProviderExtension::updateSpatialNode(QSSGRenderGraphObject *node)
103{
104 return QQuick3DRenderExtension::updateSpatialNode(node);
105}
106
107QQuick3DTextureProviderExtension::SamplerHint QQuick3DTextureProviderExtension::samplerHint() const
108{
109 Q_D(const QQuick3DTextureProviderExtension);
110 return d->samplerHint;
111}
112
113void QQuick3DTextureProviderExtension::setSamplerHint(SamplerHint newSamplerHint)
114{
115 Q_D(QQuick3DTextureProviderExtension);
116 if (d->samplerHint == newSamplerHint)
117 return;
118 d->samplerHint = newSamplerHint;
119 emit samplerHintChanged();
120}
121
122QT_END_NAMESPACE