Inherited by: QSGDynamicTexture
Users can freely implement their own texture classes to support arbitrary input textures, such as YUV video frames or 8 bit alpha masks. The scene graph provides a default implementation for RGBA textures.The default implementation is not instantiated directly, rather they are constructed via factory functions, such as
With the default implementation, each
QSGTexture is backed by a QRhiTexture, which in turn contains a native texture object, such as an OpenGL texture or a Vulkan image.
Materials that work with textures reimplement
updateSampledImage() to provide logic that decides which
QSGTexture ‘s underlying native texture should be exposed at a given shader resource binding point.
QSGTexture does not separate image (texture) and sampler objects. The parameters for filtering and wrapping can be specified with
setVerticalWrapMode() . The scene graph and Qt’s graphics abstraction takes care of creating separate sampler objects, when applicable.
Some scene graph backends use texture atlasses, grouping multiple small textures into one large texture. If this is the case, the function
isAtlasTexture() will return true. Atlases are used to aid the rendering algorithm to do better sorting which increases performance. Atlases are also essential for batching (merging together geometry to reduce the number of draw calls), because two instances of the same material using two different QSGTextures are not batchable, whereas if both QSGTextures refer to the same atlas, batching can happen, assuming the materials are otherwise compatible.
The location of the texture inside the atlas is given with the
If the texture is used in such a way that atlas is not preferable, the function
removedFromAtlas() can be used to extract a non-atlased copy.
All classes with QSG prefix should be used solely on the scene graph’s rendering thread. See Scene Graph and Rendering for more information.
Scene Graph - Rendering FBOs
QSGTexture base class.
Specifies how the sampler should treat texture coordinates.
Only the fractional part of the texture coordinate is used, causing values above 1 and below 0 to repeat.
Values above 1 are clamped to 1 and values below 0 are clamped to 0.
When the texture coordinate is even, only the fractional part is used. When odd, the texture coordinate is set to
1 - fractional part. This value has been introduced in Qt 5.10.
Specifies how sampling of texels should filter when texture coordinates are not pixel aligned.
No filtering should occur. This value is only used together with
Sampling returns the nearest texel.
Sampling returns a linear interpolation of the neighboring texels.
Specifies the anisotropic filtering level to be used when the texture is not screen aligned.
No anisotropic filtering.
2x anisotropic filtering.
4x anisotropic filtering.
8x anisotropic filtering.
16x anisotropic filtering.
New in version 5.9.
Returns the anisotropy level in use for filtering this texture.
- Return type
Returns a key suitable for comparing textures. Typically used in
QSGTexture pointers is not always sufficient because two
QSGTexture instances that refer to the same native texture object underneath should also be considered equal. Hence the need for this function.
Implementations of this function are not expected to, and should not create any graphics resources (native texture objects) in case there are none yet.
QSGTexture that does not have a native texture object underneath is typically not equal to any other
QSGTexture , so the return value has to be crafted accordingly. There are exceptions to this, in particular when atlasing is used (where multiple textures share the same atlas texture under the hood), that is then up to the subclass implementations to deal with as appropriate.
This function can only be called from the rendering thread.
rect converted to normalized coordinates.
Returns the sampling mode to be used for this texture.
- Return type
Returns true if the texture data contains an alpha channel.
- Return type
Returns true if the texture data contains mipmap levels.
Returns the horizontal wrap mode to be used for this texture.
- Return type
Returns whether this texture is part of an atlas or not.
The default implementation returns false.
Returns whether mipmapping should be used when sampling from this texture.
Returns the rectangle inside
textureSize() that this texture represents in normalized coordinates.
The default implementation returns a rect at position (0, 0) with width and height of 1.
Sets the level of anisotropic filtering to
level. The default value is
AnisotropyNone , which means no anisotropic filtering is enabled.
The request may be ignored depending on the graphics API in use. There is no guarantee anisotropic filtering is supported at run time.
Sets the sampling mode to
Sets the horizontal wrap mode to
Sets the mipmap sampling mode to
Setting the mipmap filtering has no effect it the texture does not have mipmaps.
Sets the vertical wrap mode to
Returns the size of the texture.
Returns the vertical wrap mode to be used for this texture.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.