Crafter.Graphics
C++ graphics library using Wayland and Vulkan.
 
Loading...
Searching...
No Matches
Crafter::VulkanTexture< PixelType > Class Template Referenceexport

Represents a Vulkan texture with pixel data of a specified type. More...

Public Member Functions

 VulkanTexture (std::uint32_t width, std::uint32_t height, VkCommandBuffer cmd)
 Constructs a VulkanTexture with the given dimensions.
 
 VulkanTexture (const char *asset, VkCommandBuffer cmd)
 Constructs a VulkanTexture by loading from an in memory asset.
 
void Update (const PixelType *bufferdata, VkCommandBuffer cmd)
 Updates the texture with new pixel data.
 

Public Attributes

uint32_t width
 
uint32_t height
 

Detailed Description

template<typename PixelType>
class Crafter::VulkanTexture< PixelType >

Represents a Vulkan texture with pixel data of a specified type.

This class manages a Vulkan image resource along with its associated memory, buffer, and image view. It provides functionality to create textures either by specifying dimensions or loading from an asset, and to update the texture data on the GPU using command buffers.

Template Parameters
PixelTypeThe type of the pixel data stored in the texture.

Constructor & Destructor Documentation

◆ VulkanTexture() [1/2]

template<typename PixelType>
Crafter::VulkanTexture< PixelType >::VulkanTexture ( std::uint32_t width,
std::uint32_t height,
VkCommandBuffer cmd )
inline

Constructs a VulkanTexture with the given dimensions.

Creates a Vulkan texture image with the specified width and height, initializing necessary resources.

Parameters
widthThe width of the texture.
heightThe height of the texture.
cmdVulkan command buffer used for resource initialization.

◆ VulkanTexture() [2/2]

template<typename PixelType>
Crafter::VulkanTexture< PixelType >::VulkanTexture ( const char * asset,
VkCommandBuffer cmd )
inline

Constructs a VulkanTexture by loading from an in memory asset.

Loads texture pixel data from the specified asset and initializes the Vulkan image resource accordingly.

Parameters
assetPointer to the in memory asset.
cmdVulkan command buffer used for resource initialization.

Member Function Documentation

◆ Update()

template<typename PixelType>
void Crafter::VulkanTexture< PixelType >::Update ( const PixelType * bufferdata,
VkCommandBuffer cmd )
inline

Updates the texture with new pixel data.

Copies the given pixel data into the texture's buffer and issues Vulkan commands to upload the data to the GPU image.

Parameters
bufferdataPointer to the new pixel data.
cmdVulkan command buffer used for the update operation.

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