utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
utility::graphic::Texture Class Reference

The Texture class represents a texture resource that can be used for rendering in a graphics application. More...

#include <headers/utility/graphic/texture.hpp>

Public Types

enum class  TextureType { Albedo , Normal , Roughness , FontAtlas }
 Describes the type of texture, such as albedo, normal, roughness, or font atlas. More...
 

Public Member Functions

 Texture (uint32_t width, uint32_t height, TextureType type=TextureType::Albedo)
 Constructs a Texture object with the specified width and height.
 
 ~Texture ()=default
 Destructs the Texture object.
 
uint32_t width () const
 Retrieves the width of the texture.
 
uint32_t height () const
 Retrieves the height of the texture.
 
const std::vector< uint8_t > & pixels () const noexcept
 Retrieve the pixel data.
 
std::vector< uint8_t > & pixels () noexcept
 Retrieve the pixel data for mutation.
 
TextureType type () const noexcept
 Retrieve the type of the texture.
 

Protected Attributes

std::vector< uint8_t > _pixels
 The corresponding pixel data for this texture, stored as a vector of bytes (RGBA format).
 
TextureType _type
 The type of the texture.
 
uint32_t _width
 The width of the texture in pixels.
 
uint32_t _height
 The height of the texture in pixels.
 

Detailed Description

The Texture class represents a texture resource that can be used for rendering in a graphics application.

The Texture class manages pixel data for a texture, including its width and height. It provides functionality to store and retrieve pixel data, which can be used for rendering operations in conjunction with shaders and materials.

Definition at line 25 of file texture.hpp.

Member Enumeration Documentation

◆ TextureType

Describes the type of texture, such as albedo, normal, roughness, or font atlas.

Enumerator
Albedo 

Represents the albedo (diffuse) texture, which defines the base color of a material.

Normal 

Represents the normal map texture, which encodes surface normals for detailed lighting effects.

Roughness 

Represents the roughness texture, which defines the surface roughness for specular reflections.

FontAtlas 

Represents the font atlas texture, which contains pre-rendered glyphs for text rendering.

Definition at line 32 of file texture.hpp.

Constructor & Destructor Documentation

◆ Texture()

utility::graphic::Texture::Texture ( uint32_t  width,
uint32_t  height,
TextureType  type = TextureType::Albedo 
)

Constructs a Texture object with the specified width and height.

This constructor initializes a Texture object with the given width and height, and it sets up the internal pixel data storage for the texture. The pixel data is stored as a vector of bytes in RGBA format, allowing for efficient management of texture data for rendering purposes.

Parameters
widthThe width of the texture in pixels.
heightThe height of the texture in pixels.
typeThe type of the texture.

Definition at line 12 of file texture.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ height()

uint32_t utility::graphic::Texture::height ( ) const
inline

Retrieves the height of the texture.

This method returns the height of the texture in pixels, which is stored as a member variable in the Texture class. The height is an important property of the texture that is used for rendering operations and managing texture data.

Returns
The height of the texture in pixels.

Definition at line 90 of file texture.hpp.

Here is the caller graph for this function:

◆ pixels() [1/2]

const std::vector< uint8_t > & utility::graphic::Texture::pixels ( ) const
inlinenoexcept

Retrieve the pixel data.

Returns
Read-only reference to the pixel buffer (RGBA unless this is a FontAtlas).

Definition at line 100 of file texture.hpp.

◆ pixels() [2/2]

std::vector< uint8_t > & utility::graphic::Texture::pixels ( )
inlinenoexcept

Retrieve the pixel data for mutation.

Returns
Reference to the pixel buffer. Resizing it is discouraged as it may break the width*height invariant.

Definition at line 110 of file texture.hpp.

◆ type()

TextureType utility::graphic::Texture::type ( ) const
inlinenoexcept

Retrieve the type of the texture.

Returns
The texture type.

Definition at line 119 of file texture.hpp.

Here is the caller graph for this function:

◆ width()

uint32_t utility::graphic::Texture::width ( ) const
inline

Retrieves the width of the texture.

This method returns the width of the texture in pixels, which is stored as a member variable in the Texture class. The width is an important property of the texture that is used for rendering operations and managing texture data.

Returns
The width of the texture in pixels.

Definition at line 75 of file texture.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ _height

uint32_t utility::graphic::Texture::_height
protected

The height of the texture in pixels.

Definition at line 144 of file texture.hpp.

◆ _pixels

std::vector<uint8_t> utility::graphic::Texture::_pixels
protected

The corresponding pixel data for this texture, stored as a vector of bytes (RGBA format).

Definition at line 129 of file texture.hpp.

◆ _type

TextureType utility::graphic::Texture::_type
protected

The type of the texture.

Definition at line 134 of file texture.hpp.

◆ _width

uint32_t utility::graphic::Texture::_width
protected

The width of the texture in pixels.

Definition at line 139 of file texture.hpp.


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