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
7#include <QtQuick3D/private/qquick3dobject_p.h>
9
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 \qmltype TextureProviderExtension
36 \nativetype QQuick3DTextureProviderExtension
37 \inqmlmodule QtQuick3D
38 \inherits RenderExtension
39 \since 6.11
40 \brief Abstract base type for render extensions that produce a texture.
41
42 TextureProviderExtension is an uncreatable abstract base type for render extensions
43 that expose a GPU texture to the Qt Quick 3D scene. Subclasses (such as
44 \l RenderOutputProvider) can be assigned to the \l {Texture::textureProvider}
45 {textureProvider} property of a \l Texture, causing the extension's render code
46 to run automatically when the texture is needed by the scene.
47
48 \sa RenderOutputProvider, QQuick3DTextureProviderExtension, QSSGRenderExtension
49*/
50
51/*!
52 \property QQuick3DTextureProviderExtension::samplerHint
53 \since 6.11
54
55 This property contains a hint about the type of texture that will be
56 provided by the extension. This is necessary because the texture data will
57 not be provided until it is necessary, but materials that use the Texture
58 component need to know what type of sampler to provide.
59
60 The default value is \c QQuick3DTextureProviderExtension::Sampler2D.
61
62 \note This property is only used when using CustomMaterials.
63
64 \sa SamplerHint
65*/
66/*!
67 \qmlproperty enumeration TextureProviderExtension::samplerHint
68
69 This property contains a hint about the type of texture that will be provided by the extension.
70 This is necessary because the texture data will not be provided until it is necessary, but materials
71 that use the Texture component need to know what type of sampler to provide. This property should
72 be set to one of the following values:
73
74 \value TextureProviderExtension.Sampler2D The texture will be a 2D texture.
75 \value TextureProviderExtension.Sampler2DArray The texture will be an array texture.
76 \value TextureProviderExtension.Sampler3D The texture will be a 3D texture.
77 \value TextureProviderExtension.SamplerCube The texture will be a cube map texture.
78 \value TextureProviderExtension.SamplerCubeArray The texture will be an array of cube map textures.
79 \value TextureProviderExtension.SamplerBuffer The texture will be a buffer texture.
80
81 The default value is \c TextureProviderExtension.Sampler2D.
82
83 \note This property is only used when using CustomMaterials.
84*/
85
86
87QQuick3DTextureProviderExtensionPrivate::QQuick3DTextureProviderExtensionPrivate()
88 : QQuick3DObjectPrivate(QQuick3DObjectPrivate::Type::TextureProvider)
89{
90
91}
92
93
94QQuick3DTextureProviderExtension::QQuick3DTextureProviderExtension(QQuick3DObject *parent)
95 : QQuick3DRenderExtension(*new QQuick3DTextureProviderExtensionPrivate(), parent)
96{
97
98}
99
100QQuick3DTextureProviderExtension::~QQuick3DTextureProviderExtension()
101{
102
103}
104
105/*!
106 \fn QSSGRenderGraphObject *QQuick3DTextureProviderExtension::updateSpatialNode(QSSGRenderGraphObject *node)
107
108 This function is called during the synchronization of the QtQuick3D scene graph when an item is
109 created or when an update is requested, usually as a result of a change in the item's properties.
110 The function should return a QSSGRenderTextureProviderExtension instance that contains the code that should be
111 run during QtQuick3D's rendering pipeline execution.
112
113 The \a node parameter is the previous QSSGRenderTextureProviderExtension instance that was returned from this
114 function, or null if this is the first time the function is called. The function can return the
115 same instance, a different instance, or null. If the function returns null, the extension will
116 be removed from the rendering pipeline.
117
118 \note The QSSGRenderTextureProviderExtension instance is a resource object and will be owned by the QtQuick3D
119 scene graph. If a different instance, or null, is returned, the previous instance will be
120 queued for deletion by the renderer.
121
122 \sa QSSGRenderTextureProviderExtension
123*/
124
125QSSGRenderGraphObject *QQuick3DTextureProviderExtension::updateSpatialNode(QSSGRenderGraphObject *node)
126{
127 return QQuick3DRenderExtension::updateSpatialNode(node);
128}
129
130QQuick3DTextureProviderExtension::SamplerHint QQuick3DTextureProviderExtension::samplerHint() const
131{
132 Q_D(const QQuick3DTextureProviderExtension);
133 return d->samplerHint;
134}
135
136void QQuick3DTextureProviderExtension::setSamplerHint(SamplerHint newSamplerHint)
137{
138 Q_D(QQuick3DTextureProviderExtension);
139 if (d->samplerHint == newSamplerHint)
140 return;
141 d->samplerHint = newSamplerHint;
142 emit samplerHintChanged();
143}
144
145bool QQuick3DTextureProviderExtension::event(QEvent *event)
146{
147 return QQuick3DRenderExtension::event(event);
148}
149
150QT_END_NAMESPACE
Combined button and popup list for selecting options.