Texture implementation that uses SDL3's GPU API.
More...
#include <TGUI/Backend/Renderer/SDL_GPU/BackendTextureSDLGPU.hpp>
|
| BackendTextureSDLGPU (SDL_GPUDevice *device, std::uint32_t usageFlags=SDL_GPU_TEXTUREUSAGE_SAMPLER) |
| Constructor.
|
|
| ~BackendTextureSDLGPU () override |
| Destructor.
|
|
bool | loadTextureOnly (Vector2u size, const std::uint8_t *pixels, bool smooth) override |
| Loads the texture from an array of 32-bits RGBA pixels, but don't take ownership of the pixels.
|
|
SDL_GPUTexture * | getInternalTexture () const |
| Returns a pointer to the internal SDL_GPUTexture.
|
|
void | replaceInternalTexture (SDL_GPUTexture *texture, Vector2u imageSize) |
| Replaces the internal texture by a different one.
|
|
| BackendTexture (const BackendTexture &)=delete |
|
| BackendTexture (BackendTexture &&)=delete |
|
BackendTexture & | operator= (const BackendTexture &)=delete |
|
BackendTexture & | operator= (BackendTexture &&)=delete |
|
| BackendTexture ()=default |
| Default constructor.
|
|
virtual | ~BackendTexture ()=default |
| Virtual destructor.
|
|
bool | load (Vector2u size, std::unique_ptr< std::uint8_t[]> pixels, bool smooth) |
| Loads the texture from an array of 32-bits RGBA pixels.
|
|
Vector2u | getSize () const |
| Returns the size of the entire image.
|
|
virtual void | setSmooth (bool smooth) |
| Changes whether the smooth filter is enabled or not.
|
|
bool | isSmooth () const |
| Returns whether the smooth filter is enabled or not.
|
|
bool | isTransparentPixel (Vector2u pixel) const |
| Checks if a certain pixel is transparent.
|
|
const std::uint8_t * | getPixels () const |
| Returns a pointer to the pixels (read-only)
|
|
|
SDL_GPUDevice * | m_device |
|
SDL_GPUTexture * | m_texture = nullptr |
|
std::uint32_t | m_usageFlags |
|
Vector2u | m_imageSize |
|
std::unique_ptr< std::uint8_t[]> | m_pixels |
|
bool | m_isSmooth = true |
|
Texture implementation that uses SDL3's GPU API.
◆ BackendTextureSDLGPU()
tgui::BackendTextureSDLGPU::BackendTextureSDLGPU |
( |
SDL_GPUDevice * | device, |
|
|
std::uint32_t | usageFlags = SDL_GPU_TEXTUREUSAGE_SAMPLER ) |
Constructor.
- Parameters
-
device | The device to use when creating textures |
usageFlags | Texture usage flags (SDL_GPU_TEXTUREUSAGE_SAMPLER is needed to use in a pixel shader, SDL_GPU_TEXTUREUSAGE_COLOR_TARGET would be used if you want to use it as a render target). |
◆ getInternalTexture()
SDL_GPUTexture * tgui::BackendTextureSDLGPU::getInternalTexture |
( |
| ) |
const |
|
inlinenodiscard |
Returns a pointer to the internal SDL_GPUTexture.
- Returns
- Pointer to internal texture
◆ loadTextureOnly()
bool tgui::BackendTextureSDLGPU::loadTextureOnly |
( |
Vector2u | size, |
|
|
const std::uint8_t * | pixels, |
|
|
bool | smooth ) |
|
overridevirtual |
Loads the texture from an array of 32-bits RGBA pixels, but don't take ownership of the pixels.
- Parameters
-
size | Width and height of the image to create |
pixels | Pointer to array of size.x*size.y*4 bytes with RGBA pixels, or nullptr to create an empty texture |
smooth | Should the smooth filter be enabled or not? |
- Warning
- Unlike the load function, loadTextureOnly won't store the pixels and isTransparentPixel thus won't work
Reimplemented from tgui::BackendTexture.
◆ replaceInternalTexture()
void tgui::BackendTextureSDLGPU::replaceInternalTexture |
( |
SDL_GPUTexture * | texture, |
|
|
Vector2u | imageSize ) |
Replaces the internal texture by a different one.
- Parameters
-
texture | Texture to copy |
imageSize | Dimensions of the new texture |
This will remove the pixel data stored by this object and reset its size based on the given imageSize parameter.
- Warning
- Ownership of the texture is transferred by calling this function. The SDL_ReleaseGPUTexture function will be called when this object is destroyed and it should NOT be called by the caller of replaceInternalTexture.
The documentation for this class was generated from the following file: