![]() |
Qt 6.x
The Qt SDK
|
\qmltype TextureData \inherits Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DTextureData More...
#include <qquick3dtexturedata.h>
Public Types | |
enum | Format { None , RGBA8 , RGBA16F , RGBA32F , RGBE8 , R8 , R16 , R16F , R32F , BC1 , BC2 , BC3 , BC4 , BC5 , BC6H , BC7 , DXT1_RGBA , DXT1_RGB , DXT3_RGBA , DXT5_RGBA , ETC2_RGB8 , ETC2_RGB8A1 , ETC2_RGBA8 , ASTC_4x4 , ASTC_5x4 , ASTC_5x5 , ASTC_6x5 , ASTC_6x6 , ASTC_8x5 , ASTC_8x6 , ASTC_8x8 , ASTC_10x5 , ASTC_10x6 , ASTC_10x8 , ASTC_10x10 , ASTC_12x10 , ASTC_12x12 } |
Returns the color format of the texture data assigned in \l textureData property. More... | |
Signals | |
void | textureDataNodeDirty () |
![]() | |
void | parentChanged () |
void | childrenChanged () |
void | stateChanged () |
![]() | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
QQuick3DTextureData (QQuick3DObject *parent=nullptr) | |
~QQuick3DTextureData () | |
const QByteArray | textureData () const |
Returns the current texture data defined by this item. | |
void | setTextureData (const QByteArray &data) |
Sets the texture data. | |
QSize | size () const |
Returns the size of the texture data in pixels. | |
void | setSize (const QSize &size) |
Sets the size of the texture data in pixels. | |
int | depth () const |
Returns the depth of the texture data in pixels. | |
void | setDepth (int depth) |
Sets the depth of the texture data in pixels. | |
Format | format () const |
Returns the format of the texture data. | |
void | setFormat (Format format) |
Sets the format of the texture data. | |
bool | hasTransparency () const |
Returns true if the texture data has transparency. | |
void | setHasTransparency (bool hasTransparency) |
Set hasTransparency to true if the texture data has an active alpha channel with non-opaque values. | |
![]() | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
![]() | |
QQmlParserStatus () | |
virtual | ~QQmlParserStatus () |
virtual void | classBegin ()=0 |
Invoked after class creation, but before any properties have been set. | |
virtual void | componentComplete ()=0 |
Invoked after the root component that caused this instantiation has completed construction. | |
Protected Member Functions | |
QSSGRenderGraphObject * | updateSpatialNode (QSSGRenderGraphObject *node) override |
void | markAllDirty () override |
![]() | |
virtual QSSGRenderGraphObject * | updateSpatialNode (QSSGRenderGraphObject *node) |
virtual void | markAllDirty () |
virtual void | itemChange (ItemChange, const ItemChangeData &) |
QQuick3DObject (QQuick3DObjectPrivate &dd, QQuick3DObject *parent=nullptr) | |
void | classBegin () override |
Invoked after class creation, but before any properties have been set. | |
void | componentComplete () override |
Invoked after the root component that caused this instantiation has completed construction. | |
bool | isComponentComplete () const |
virtual void | preSync () |
![]() | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
Additional Inherited Members | |
![]() | |
void | update () |
void | setParentItem (QQuick3DObject *parentItem) |
![]() | |
void | deleteLater () |
\threadsafe | |
![]() | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a connection. | |
template<typename Func1 , typename Func2 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
template<typename Func1 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
QQuick3DObject * | parent |
\qmlproperty Object3D QtQuick3D::Object3D::parent This property holds the parent of the Object3D in a 3D scene. | |
![]() | |
QString | objectName |
the name of this object | |
![]() | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
\qmltype TextureData \inherits Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DTextureData
Base type for custom texture data.
Custom texture data allows using application-generated texture data, that can possibly change dynamically as well. To use custom texture data set the \l{Texture::textureData}{textureData} property of \l {Texture} to reference a TextureData object.
Custom Texture data is implemented in C++ by creating a QQuick3DTextureData instance, often subclassing it. The QQuick3DTextureData type is registered to QML under the name of TextureData. Once the subclass is registered to QML, Texture objects can start referencing it.
An example of when to use this API is when there is a need to procedurally generate a texture at runtime rather than loading a static image from a file.
\inmodule QtQuick3D \inherits QQuick3DObject
Base class for defining custom texture data.
The QQuick3DTextureData class can be used to specify custom texture data for a \l {Texture} in a Qt Quick 3D scene.
While not strictly required, the typical usage is to inherit from this class. The subclass is then exposed to QML by registering it to the type system. The \l{Texture::textureData}{textureData} property of a \l {QtQuick3D::Texture}{Texture} can then be set to reference an instance of the registered type.
Example implementation:
This class can then be registered as a QML type and used with \l {QtQuick3D::Texture}{Texture}.
In Qt 5 type registration happened with qmlRegisterType:
In Qt 6 the default approach is to use automatic registration with the help of the build system. Instead of calling qmlRegisterType, the {.pro} file can now contain:
With CMake, automatic registration is the default behavior, so no special settings are needed beyond basic QML module setup:
The class implementation should add QML_NAMED_ELEMENT:
The QML code can then use the custom type:
Definition at line 13 of file qquick3dtexturedata.h.
Returns the color format of the texture data assigned in \l textureData property.
\value None The color format is not defined \value RGBA8 The color format is considered as 8-bit integer in R, G, B and alpha channels. \value RGBA16F The color format is considered as 16-bit float in R,G,B and alpha channels. \value RGBA32F The color format is considered as 32-bit float in R, G, B and alpha channels. \value RGBE8 The color format is considered as 8-bit mantissa in the R, G, and B channels and 8-bit shared exponent. \value R8 The color format is considered as 8-bit integer in R channel. \value R16 The color format is considered as 16-bit integer in R channel. \value R16F The color format is considered as 16-bit float in R channel. \value R32F The color format is considered as 32-bit float R channel. \value BC1 The color format is considred as BC1 compressed format with R, G, B, and alpha channels. \value BC2 The color format is considred as BC2 compressed format with R, G, B, and alpha channels. \value BC3 The color format is considred as BC3 compressed format with R, G, B, and alpha channels. \value BC4 The color format is considred as BC4 compressed format with one color channel. \value BC5 The color format is considred as BC5 compressed format with two color channels. \value BC6H The color format is considred as BC6H compressed format with three high dynamic range color channels. \value BC7 The color format is considred as BC7 compressed format with R, G, B, and alpha channels. \value DXT1_RGBA The color format is considered as DXT1 compressed format with R, G, B and alpha channels. \value DXT1_RGB The color format is considered as DXT1 compressed format with R, G and B channels. \value DXT3_RGBA The color format is considered as DXT3 compressed format with R, G, B and alpha channels. \value DXT5_RGBA The color format is considered as DXT5 compressed format with R, G, B and alpha channels. \value ETC2_RGB8 The color format is considered as ETC2 compressed format for RGB888 data \value ETC2_RGB8A1 The color format is considered as ETC2 compressed format for RGBA data where alpha is 1-bit. \value ETC2_RGBA8 The color format is considered as ETC2 compressed format with RGBA8888 data. \value ASTC_4x4 The color format is considered as ASTC compressed format with 4x4 block footprint. \value ASTC_5x4 The color format is considered as ASTC compressed format with 5x4 block footprint. \value ASTC_5x5 The color format is considered as ASTC compressed format with 5x5 block footprint. \value ASTC_6x5 The color format is considered as ASTC compressed format with 6x5 block footprint. \value ASTC_6x6 The color format is considered as ASTC compressed format with 6x6 block footprint. \value ASTC_8x5 The color format is considered as ASTC compressed format with 8x5 block footprint. \value ASTC_8x6 The color format is considered as ASTC compressed format with 8x6 block footprint. \value ASTC_8x8 The color format is considered as ASTC compressed format with 8x8 block footprint. \value ASTC_10x5 The color format is considered as ASTC compressed format with 10x5 block footprint. \value ASTC_10x6 The color format is considered as ASTC compressed format with 10x6 block footprint. \value ASTC_10x8 The color format is considered as ASTC compressed format with 10x8 block footprint. \value ASTC_10x10 The color format is considered as ASTC compressed format with 10x10 block footprint. \value ASTC_12x10 The color format is considered as ASTC compressed format with 12x10 block footprint. \value ASTC_12x12 The color format is considered as ASTC compressed format with 12x12 block footprint.
RGBA8
, not every format is supported at runtime as this depends on which backend is being used as well which hardware is being used.RGBE
is internally represented as an RGBA8
but is intepreted as described when used as a lightProbe or skybox texture.None
will assume the default value of RGBA8
Definition at line 22 of file qquick3dtexturedata.h.
QQuick3DTextureData::QQuick3DTextureData | ( | QQuick3DObject * | parent = nullptr | ) |
Definition at line 222 of file qquick3dtexturedata.cpp.
QQuick3DTextureData::~QQuick3DTextureData | ( | ) |
Definition at line 228 of file qquick3dtexturedata.cpp.
int QQuick3DTextureData::depth | ( | ) | const |
Returns the depth of the texture data in pixels.
Definition at line 280 of file qquick3dtexturedata.cpp.
References d.
Referenced by QQuick3DTextureDataFrontend::depth(), setDepth(), QQuick3DTextureDataFrontend::setDepth(), and QQuick3DCustomMaterial::updateSpatialNode().
QQuick3DTextureData::Format QQuick3DTextureData::format | ( | ) | const |
Returns the format of the texture data.
Definition at line 300 of file qquick3dtexturedata.cpp.
References d.
Referenced by QQuick3DTextureDataFrontend::format(), QQuick3DTextureDataFrontend::setFormat(), and setFormat().
bool QQuick3DTextureData::hasTransparency | ( | ) | const |
Returns true
if the texture data has transparency.
The default value is false
.
Definition at line 323 of file qquick3dtexturedata.cpp.
References d.
Referenced by QQuick3DTextureDataFrontend::hasTransparency(), setHasTransparency(), and QQuick3DTextureDataFrontend::setHasTransparency().
|
overrideprotectedvirtual |
Reimplemented from QQuick3DObject.
Definition at line 478 of file qquick3dtexturedata.cpp.
References QQuick3DObject::markAllDirty().
Referenced by updateSpatialNode().
void QQuick3DTextureData::setDepth | ( | int | depth | ) |
Sets the depth of the texture data in pixels.
Setting the depth above 0 means that the texture is handled as a 3D texture.
Definition at line 290 of file qquick3dtexturedata.cpp.
References d, depth(), and QQuick3DObject::update().
Referenced by QQuick3DTextureDataFrontend::setDepth().
void QQuick3DTextureData::setFormat | ( | QQuick3DTextureData::Format | format | ) |
Sets the format of the texture data.
The default format is /c RGBA8
Definition at line 311 of file qquick3dtexturedata.cpp.
References d, format(), and QQuick3DObject::update().
Referenced by ProceduralSkyTextureData::generateRGBA16FTexture(), and QQuick3DTextureDataFrontend::setFormat().
void QQuick3DTextureData::setHasTransparency | ( | bool | hasTransparency | ) |
Set hasTransparency to true if the texture data has an active alpha channel with non-opaque values.
This is used as an optimization by the engine so that for formats that do support an alpha channel do not need to have each value checked for non-opaque values.
Definition at line 337 of file qquick3dtexturedata.cpp.
References d, hasTransparency(), and QQuick3DObject::update().
Referenced by ProceduralSkyTextureData::generateRGBA16FTexture(), and QQuick3DTextureDataFrontend::setHasTransparency().
Sets the size of the texture data in pixels.
Definition at line 270 of file qquick3dtexturedata.cpp.
References d, size(), and QQuick3DObject::update().
Referenced by ProceduralSkyTextureData::generateRGBA16FTexture(), QQuick3DTextureDataFrontend::setHeight(), and QQuick3DTextureDataFrontend::setWidth().
void QQuick3DTextureData::setTextureData | ( | const QByteArray & | data | ) |
Sets the texture data.
The contents of data must respect the \l size and \l format properties as the backend will try and upload and use the data as if it were a texture of size and format, and if there is any deviation the result will be somewhere between incorrect rendering of the texture, or potentially a crash.
Definition at line 250 of file qquick3dtexturedata.cpp.
References d, and QQuick3DObject::update().
Referenced by ProceduralSkyTextureData::generateRGBA16FTexture(), and QQuick3DTextureDataFrontend::setTextureData().
QSize QQuick3DTextureData::size | ( | ) | const |
Returns the size of the texture data in pixels.
Definition at line 261 of file qquick3dtexturedata.cpp.
References d.
Referenced by ProceduralSkyTextureData::generateRGBA16FTexture(), QQuick3DTextureDataFrontend::height(), QQuick3DTextureDataFrontend::setHeight(), setSize(), QQuick3DTextureDataFrontend::setWidth(), and QQuick3DTextureDataFrontend::width().
const QByteArray QQuick3DTextureData::textureData | ( | ) | const |
Returns the current texture data defined by this item.
Definition at line 236 of file qquick3dtexturedata.cpp.
References d.
Referenced by QQuick3DTextureDataFrontend::textureData(), and updateSpatialNode().
|
signal |
Referenced by QQuick3DTexture::setTextureData(), and updateSpatialNode().
|
overrideprotectedvirtual |
Reimplemented from QQuick3DObject.
Definition at line 429 of file qquick3dtexturedata.cpp.
References convertToBackendFormat(), d, emit, DebugViewHelpers::ensureDebugObjectName(), markAllDirty(), QByteArray::size(), textureData(), textureDataNodeDirty(), and QQuick3DObject::updateSpatialNode().