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
// Qt-Security score:significant reason:default
4
5
6
#
include
"qquick3dtextureproviderextension.h"
7
#
include
<
QtQuick3D
/
private
/
qquick3dobject_p
.
h
>
8
#
include
"qquick3dtextureproviderextension_p.h"
9
10
QT_BEGIN_NAMESPACE
11
12
/*!
13
\class QQuick3DTextureProviderExtension
14
\inmodule QtQuick3D
15
\since 6.11
16
17
\brief Abstract class for implementing user side texture provider extensions.
18
19
This is the front-end side of a texture provider extension. The back-end side is implemented
20
in \l QSSGRenderExtension. The QQuick3DTextureProviderExtension is a specialization of the
21
QQuick3DRenderExtension class that is used to create a custom texture provider extension that can
22
both provide additional metadata about what type of texture will be provided and also automatically
23
register the extension with the QtQuick3D scene graph. This means it is unecessary to manually add
24
the extension to the list of extensions to be used with a \l View3D, and just using the textureProvider
25
property of the Texture component is enough to trigger the extension code to be run when necessary.
26
27
The QQuick3DTextureProviderExtension class is an abstract class that should be subclassed and
28
exposed to QML. The subclass should implement the \l QQuick3DRenderExtension::updateSpatialNode()
29
function and return a QSSGRenderExtension instance that contains the code that should be run.
30
31
\sa QSSGRenderExtension
32
*/
33
34
/*!
35
\enum QQuick3DTextureProviderExtension::SamplerHint
36
37
Specifies a hint about the type of texture that will be
38
provided by the extension.
39
40
\value Sampler2D A 2D texture
41
\value Sampler2DArray An array texture
42
\value Sampler3D A 3D texture
43
\value SamplerCube A cube map texture
44
\value SamplerCubeArray An array of cube map textures
45
\value SamplerBuffer A buffer texture
46
47
*/
48
49
/*!
50
\qmltype TextureProviderExtension
51
\nativetype QQuick3DTextureProviderExtension
52
\inqmlmodule QtQuick3D
53
\inherits RenderExtension
54
\since 6.11
55
\brief Abstract base type for render extensions that produce a texture.
56
57
TextureProviderExtension is an uncreatable abstract base type for render extensions
58
that expose a GPU texture to the Qt Quick 3D scene. Subclasses (such as
59
\l RenderOutputProvider) can be assigned to the \l {Texture::textureProvider}
60
{textureProvider} property of a \l Texture, causing the extension's render code
61
to run automatically when the texture is needed by the scene.
62
63
\sa RenderOutputProvider, QQuick3DTextureProviderExtension, QSSGRenderExtension
64
*/
65
66
/*!
67
\property QQuick3DTextureProviderExtension::samplerHint
68
\since 6.11
69
70
This property contains a hint about the type of texture that will be
71
provided by the extension. This is necessary because the texture data will
72
not be provided until it is necessary, but materials that use the Texture
73
component need to know what type of sampler to provide.
74
75
The default value is \c QQuick3DTextureProviderExtension::Sampler2D.
76
77
\note This property is only used when using CustomMaterials.
78
79
\sa SamplerHint
80
*/
81
82
/*!
83
\qmlenum TextureProviderExtension::SamplerHint
84
\qmlenumeratorsfrom QQuick3DTextureProviderExtension::SamplerHint
85
\since 6.11
86
87
Specifies a hint about the type of texture the extension provides.
88
89
*/
90
91
/*!
92
\qmlproperty SamplerHint TextureProviderExtension::samplerHint
93
\since 6.11
94
95
This property contains a hint about the type of texture that will be provided by the extension.
96
This is necessary because the texture data will not be provided until it is necessary, but materials
97
that use the Texture component need to know what type of sampler to provide.
98
99
The default value is \c TextureProviderExtension.Sampler2D.
100
101
\note This property is only used when using CustomMaterials.
102
*/
103
104
105
QQuick3DTextureProviderExtensionPrivate::QQuick3DTextureProviderExtensionPrivate()
106
: QQuick3DObjectPrivate(QQuick3DObjectPrivate::Type::TextureProvider)
107
{
108
109
}
110
111
112
QQuick3DTextureProviderExtension::QQuick3DTextureProviderExtension(QQuick3DObject *parent)
113
: QQuick3DRenderExtension(*
new
QQuick3DTextureProviderExtensionPrivate(), parent)
114
{
115
116
}
117
118
QQuick3DTextureProviderExtension::~QQuick3DTextureProviderExtension()
119
{
120
121
}
122
123
/*!
124
\fn QSSGRenderGraphObject *QQuick3DTextureProviderExtension::updateSpatialNode(QSSGRenderGraphObject *node)
125
126
This function is called during the synchronization of the QtQuick3D scene graph when an item is
127
created or when an update is requested, usually as a result of a change in the item's properties.
128
The function should return a QSSGRenderTextureProviderExtension instance that contains the code that should be
129
run during QtQuick3D's rendering pipeline execution.
130
131
The \a node parameter is the previous QSSGRenderTextureProviderExtension instance that was returned from this
132
function, or null if this is the first time the function is called. The function can return the
133
same instance, a different instance, or null. If the function returns null, the extension will
134
be removed from the rendering pipeline.
135
136
\note The QSSGRenderTextureProviderExtension instance is a resource object and will be owned by the QtQuick3D
137
scene graph. If a different instance, or null, is returned, the previous instance will be
138
queued for deletion by the renderer.
139
140
\sa QSSGRenderTextureProviderExtension
141
*/
142
143
/*!
144
\fn void QQuick3DTextureProviderExtension::surfaceChanged()
145
\since 6.12
146
147
This signal is emitted when the underlying rendering surface has changed
148
and textures need to be recreated.
149
*/
150
151
QSSGRenderGraphObject *QQuick3DTextureProviderExtension::updateSpatialNode(QSSGRenderGraphObject *node)
152
{
153
return
QQuick3DRenderExtension::updateSpatialNode(node);
154
}
155
156
QQuick3DTextureProviderExtension::SamplerHint QQuick3DTextureProviderExtension::samplerHint()
const
157
{
158
Q_D(
const
QQuick3DTextureProviderExtension);
159
return
d->samplerHint;
160
}
161
162
void
QQuick3DTextureProviderExtension::setSamplerHint(SamplerHint newSamplerHint)
163
{
164
Q_D(QQuick3DTextureProviderExtension);
165
if
(d->samplerHint == newSamplerHint)
166
return
;
167
d->samplerHint = newSamplerHint;
168
emit samplerHintChanged();
169
}
170
171
bool
QQuick3DTextureProviderExtension::event(QEvent *event)
172
{
173
return
QQuick3DRenderExtension::event(event);
174
}
175
176
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtquick3d
src
quick3d
extensions
qquick3dtextureproviderextension.cpp
Generated on
for Qt by
1.16.1