|
Visual Computing Library
devel
|
Manages a BGFX texture. More...
#include <vclib/bgfx/texture.h>
Public Member Functions | |
| void | bind (uint stage, bgfx::UniformHandle samplerHandle, uint samplerFlags=UINT32_MAX) const |
| Binds the texture to a texture stage for rendering. | |
| bool | isValid () const |
| Checks if the Texture holds valid BGFX texture handle. | |
| Texture & | operator= (const Texture &other)=delete |
| Deleted copy assignment operator. | |
| Texture & | operator= (Texture &&other) noexcept |
| Move assignment operator. | |
| void | set (const bgfx::Memory *texture, const vcl::Point2i &size, bool hasMips, uint nLayers, bgfx::TextureFormat::Enum format=bgfx::TextureFormat::RGBA8, uint64_t flags=BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE) |
| Creates a 2D texture from a bgfx::Memory reference. | |
| void | set (const void *data, const vcl::Point2i &size, bool hasMips=false, uint64_t flags=BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE, bgfx::ReleaseFn releaseFn=nullptr) |
| Creates a 2D texture from raw pixel data. | |
| void | swap (Texture &other) |
| Swaps the content of this object with another Texture. | |
| Texture ()=default | |
| Default constructor. | |
| Texture (const Texture &other)=delete | |
| Deleted copy constructor. | |
| Texture (Texture &&other) noexcept | |
| Move constructor. | |
| ~Texture () | |
| Destructor. | |
Static Public Member Functions | |
| static uint | samplerFlagsFromTexture (const TextureDescriptor &tex) |
| Generates BGFX sampler flags based on the texture's filtering and wrapping modes. | |
Private Attributes | |
| bgfx::TextureHandle | mTextureHandle = BGFX_INVALID_HANDLE |
Friends | |
| void | swap (Texture &a, Texture &b) |
| Swaps two Texture objects. | |
Manages a BGFX texture.
This class is a RAII wrapper for a bgfx::TextureHandle. It handles the creation, destruction, and binding of a texture.
This class is move-only, as it represents a unique GPU resource.
|
default |
Deleted copy constructor.
Copying a Texture is disallowed to prevent duplicate ownership of a single GPU resource.
|
inlinenoexcept |
|
inline |
Destructor.
Destroys the managed BGFX texture if it is valid, releasing the associated GPU resource.
|
inline |
Binds the texture to a texture stage for rendering.
This method should be called within the rendering loop before submitting a draw call that uses this texture.
| [in] | stage | The texture stage (sampler index) to bind to. |
| [in] | samplerHandle | The sampler uniform handle in the shader. |
| [in] | samplerFlags | Optional BGFX sampler flags to override the flags set during creation. If set to UINT32_MAX, the creation flags are used. |
|
inline |
Checks if the Texture holds valid BGFX texture handle.
Deleted copy assignment operator.
Copy-assigning a Texture is disallowed to prevent duplicate ownership of a single GPU resource.
|
inlinestatic |
Generates BGFX sampler flags based on the texture's filtering and wrapping modes.
| [in] | tex | The TextureDescriptor object to derive sampler flags from. |
|
inline |
Creates a 2D texture from a bgfx::Memory reference.
This is the primary method for texture creation, offering full control over format, layers, and mipmaps. Any existing texture data in this object will be destroyed.
| [in] | texture | Pointer to a bgfx::Memory object containing the texture data. |
| [in] | size | The width and height of the texture. |
| [in] | hasMips | Indicates if the provided data includes mipmaps. |
| [in] | nLayers | The number of layers for a texture array. Use 1 for a standard 2D texture. |
| [in] | format | The format of the texture data. |
| [in] | flags | BGFX texture and sampler creation flags. |
|
inline |
Creates a 2D texture from raw pixel data.
This is a convenience method that creates a standard 2D RGBA8 texture. Any existing texture data in this object will be destroyed.
| [in] | data | Pointer to the raw texture data. |
| [in] | size | The width and height of the texture. |
| [in] | hasMips | Indicates if the provided data includes mipmaps. |
| [in] | flags | BGFX texture and sampler creation flags. |
| [in] | releaseFn | Optional callback function to release the data pointer when BGFX is finished with it. |