TGUI 1.14-dev
Loading...
Searching...
No Matches

Texture implementation that uses Vulkan. More...

#include <TGUI/Backend/Renderer/Vulkan/BackendTextureVulkan.hpp>

Inheritance diagram for tgui::BackendTextureVulkan:
tgui::BackendTexture

Classes

struct  ImageResources

Public Member Functions

 BackendTextureVulkan (std::shared_ptr< BackendRendererVulkan > renderer, VkImageUsageFlags additionalUsageFlags=0)
 Constructor.
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.
VkImage getInternalImage () const
 Returns the internal image.
VkImageView getInternalImageView () const
 Returns the view of the internal image.
const std::shared_ptr< ImageResources > & getImageResources () const
Public Member Functions inherited from tgui::BackendTexture
 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).

Protected Member Functions

std::shared_ptr< ImageResources > createImageResources (Vector2u size) const

Protected Attributes

std::shared_ptr< BackendRendererVulkan > m_renderer
VkImageUsageFlags m_usageFlags
std::shared_ptr< ImageResources > m_imageResources
Protected Attributes inherited from tgui::BackendTexture
Vector2u m_imageSize
std::unique_ptr< std::uint8_t[]> m_pixels
bool m_isSmooth = true

Detailed Description

Texture implementation that uses Vulkan.

The image has the VK_FORMAT_R8G8B8A8_UNORM format and is kept in the VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL layout.

Loading the texture submits the upload to the queue without waiting for it to finish. Work that accesses the image must be submitted to the same queue, with a dependency on VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT as source stage.

Constructor & Destructor Documentation

◆ BackendTextureVulkan()

tgui::BackendTextureVulkan::BackendTextureVulkan ( std::shared_ptr< BackendRendererVulkan > renderer,
VkImageUsageFlags additionalUsageFlags = 0 )

Constructor.

Parameters
rendererRenderer that holds the Vulkan device
additionalUsageFlagsUsage flags for the image, on top of VK_IMAGE_USAGE_SAMPLED_BIT and VK_IMAGE_USAGE_TRANSFER_DST_BIT which are always set.

Member Function Documentation

◆ getInternalImage()

VkImage tgui::BackendTextureVulkan::getInternalImage ( ) const
nodiscard

Returns the internal image.

Returns
Vulkan image, or VK_NULL_HANDLE if the texture hasn't been loaded yet

The image is recreated when the texture is loaded with a different size.

◆ getInternalImageView()

VkImageView tgui::BackendTextureVulkan::getInternalImageView ( ) const
nodiscard

Returns the view of the internal image.

Returns
Vulkan image view, or VK_NULL_HANDLE if the texture hasn't been loaded yet

◆ loadTextureOnly()

bool tgui::BackendTextureVulkan::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
sizeWidth and height of the image to create
pixelsPointer to array of size.x*size.y*4 bytes with RGBA pixels, or nullptr to create an empty texture
smoothShould 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.


The documentation for this class was generated from the following file: