QSGTexture ClassThe QSGTexture class is a baseclass for textures used in the scene graph. More... #include <QSGTexture> Inherits: QObject. Inherited by: QSGDynamicTexture. Public Types
Public Functions
Protected Functions
Additional Inherited Members
Detailed DescriptionThe QSGTexture class is a baseclass for textures used in the scene graph. 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 backend provides a default implementation of normal color textures. As the implementation of these may be hardware specific, they are are constructed via the factory function QQuickCanvas::createTextureFromImage(). The texture is a wrapper around an OpenGL texture, which texture id is given by textureId() and which size in pixels is given by textureSize(). hasAlphaChannel() reports if the texture contains opacity values and hasMipmaps() reports if the texture contains mipmap levels. To use a texture, call the bind() function. The texture parameters specifying how the texture is bound, can be specified with setMipmapFiltering(), setFiltering(), setHorizontalWrapMode() and setVerticalWrapMode(). The texture will internally try to store these values to minimize the OpenGL state changes when the texture is bound. Texture AtlassesSome scene graph backens use texture atlasses, grouping multiple small textures into one large texture. If this is the case, the function isAtlasTexture() will return true. Atlasses are used to aid the rendering algorithm to do better sorting which increases performance. The location of the texture inside the atlas is given with the normalizedTextureSubRect() function. If the texture is used in such a way that atlas is not preferable, the function removedFromAtlas() can be used to extract a non-atlassed copy. Member Type Documentation
|
Constant | Value | Description |
---|---|---|
QSGTexture::None | 0 | No filtering should occur. This value is only used together with setMipmapFiltering(). |
QSGTexture::Nearest | 1 | Sampling returns the nearest texel. |
QSGTexture::Linear | 2 | Sampling returns a linear interpolation of the neighboring texels. |
Specifies how the texture should treat texture coordinates.
Constant | Value | Description |
---|---|---|
QSGTexture::Repeat | 0 | Only the factional part of the texture coordiante is used, causing values above 1 and below 0 to repeat. |
QSGTexture::ClampToEdge | 1 | Values above 1 are clamped to 1 and values below 0 are clamped to 0. |
Call this function to bind this texture to the current texture target.
Binding a texture may also include uploading the texture data from a previously set QImage.
Warning: This function can only be called from the rendering thread.
See also setFiltering().
Returns true if the texture data contains mipmap levels.
See also setHorizontalWrapMode().
Returns weither 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.
See also setMipmapFiltering().
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.
This function returns a copy of the current texture which is removed from its atlas.
The current texture remains unchanged, so texture coordinates do not need to be updated.
Removing a texture from an atlas is primarily useful when passing it to a shader that operates on the texture coordinates 0-1 instead of the texture subrect inside the atlas.
If the texture is not part of a texture atlas, this function returns 0.
Implementations of this function are recommended to return the same instance for multiple calls to limit memory usage.
Warning: This function can only be called from the rendering thread.
Sets the sampling mode to be used for the upcoming bind() call to filter.
See also filtering().
Sets the horizontal wrap mode to be used for the upcoming bind() call to hwrap
See also horizontalWrapMode().
Sets the mipmap sampling mode to be used for the upcoming bind() call to filter.
Setting the mipmap filtering has no effect it the texture does not have mipmaps.
See also mipmapFiltering() and hasMipmaps().
See also verticalWrapMode().
Returns the OpenGL texture id for this texture.
The default value is 0, indicating that it is an invalid texture id.
The function should at all times return the correct texture id.
Warning: This function can only be called from the rendering thread.
Update the texture state to match the filtering, mipmap and wrap options currently set.
If force is true, all properties will be updated regardless of weither they have changed or not.
See also setVerticalWrapMode().