Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::Texture Class Reference

Represents a 2D texture image resource. More...

#include <aeongames/Texture.hpp>

Inheritance diagram for AeonGames::Texture:
Inheritance graph
Collaboration diagram for AeonGames::Texture:
Collaboration graph

Public Types

enum class  Format : uint32_t { Unknown = 0 , RGB , RGBA , BGRA }
 Pixel channel layout format. More...
enum class  Type : uint32_t { Unknown = 0 , UNSIGNED_BYTE , UNSIGNED_SHORT , UNSIGNED_INT_8_8_8_8_REV }
 Pixel component data type. More...

Public Member Functions

DLL ~Texture ()
 Destructor.
DLL void Resize (uint32_t aWidth, uint32_t aHeight, const uint8_t *aPixels=nullptr, Format aFormat=Format::Unknown, Type aType=Type::Unknown)
 Resizes the texture and optionally replaces pixel data.
DLL void WritePixels (int32_t aXOffset, int32_t aYOffset, uint32_t aWidth, uint32_t aHeight, Format aFormat, Type aType, const uint8_t *aPixels)
 Writes pixel data into a sub-region of the texture.
DLL void LoadFromMemory (const void *aBuffer, size_t aBufferSize) final
 Loads texture data from a raw memory buffer.
DLL void Unload () final
 Releases all texture data and resets the texture to an empty state.
DLL uint32_t GetWidth () const
 Returns the texture width in pixels.
DLL uint32_t GetHeight () const
 Returns the texture height in pixels.
DLL Format GetFormat () const
 Returns the pixel format.
DLL Type GetType () const
 Returns the pixel component type.
DLL const std::vector< uint8_t > & GetPixels () const
 Returns a reference to the raw pixel data.
Public Member Functions inherited from AeonGames::Resource
virtual ~Resource ()
 Virtual destructor.
DLL void LoadFromId (uint32_t aId)
 Load the resource identified by a numeric id.
DLL void LoadFromFile (const std::string &aFilename)
 Load the resource from a file on disk.
DLL size_t GetConsecutiveId () const
 Get the Consecutive Id for the resource object.

Detailed Description

Represents a 2D texture image resource.

Provides functionality for loading, resizing, and accessing pixel data in various formats and types. Supports pluggable image decoders.

Definition at line 32 of file Texture.hpp.

Member Enumeration Documentation

◆ Format

enum class AeonGames::Texture::Format : uint32_t
strong

Pixel channel layout format.

Specifies the ordering and number of color channels per pixel.

Enumerator
Unknown 

Unspecified or invalid format.

RGB 

3-channel red, green, blue.

RGBA 

4-channel red, green, blue, alpha.

BGRA 

4-channel blue, green, red, alpha.

Definition at line 39 of file Texture.hpp.

◆ Type

enum class AeonGames::Texture::Type : uint32_t
strong

Pixel component data type.

Specifies the data type used for each color channel value.

Enumerator
Unknown 

Unspecified or invalid type.

UNSIGNED_BYTE 

8-bit unsigned integer per channel.

UNSIGNED_SHORT 

16-bit unsigned integer per channel.

UNSIGNED_INT_8_8_8_8_REV 

Packed 32-bit unsigned integer with reversed byte order.

Definition at line 50 of file Texture.hpp.

Member Function Documentation

◆ GetFormat()

Texture::Format AeonGames::Texture::GetFormat ( ) const

Returns the pixel format.

Definition at line 83 of file Texture.cpp.

◆ GetHeight()

uint32_t AeonGames::Texture::GetHeight ( ) const

Returns the texture height in pixels.

Definition at line 79 of file Texture.cpp.

◆ GetPixels()

const std::vector< uint8_t > & AeonGames::Texture::GetPixels ( ) const

Returns a reference to the raw pixel data.

Definition at line 92 of file Texture.cpp.

◆ GetType()

Texture::Type AeonGames::Texture::GetType ( ) const

Returns the pixel component type.

Definition at line 87 of file Texture.cpp.

◆ GetWidth()

uint32_t AeonGames::Texture::GetWidth ( ) const

Returns the texture width in pixels.

Definition at line 75 of file Texture.cpp.

◆ LoadFromMemory()

void AeonGames::Texture::LoadFromMemory ( const void * aBuffer,
size_t aBufferSize )
finalvirtual

Loads texture data from a raw memory buffer.

Parameters
aBufferPointer to the encoded image data.
aBufferSizeSize of the buffer in bytes.

Implements AeonGames::Resource.

Definition at line 97 of file Texture.cpp.

◆ Resize()

void AeonGames::Texture::Resize ( uint32_t aWidth,
uint32_t aHeight,
const uint8_t * aPixels = nullptr,
Format aFormat = Format::Unknown,
Type aType = Type::Unknown )

Resizes the texture and optionally replaces pixel data.

Parameters
aWidthNew width in pixels.
aHeightNew height in pixels.
aPixelsOptional pointer to new pixel data.
aFormatPixel format of the new data. Keeps current format if Unknown.
aTypePixel type of the new data. Keeps current type if Unknown.

Definition at line 46 of file Texture.cpp.

◆ Unload()

void AeonGames::Texture::Unload ( )
finalvirtual

Releases all texture data and resets the texture to an empty state.

Implements AeonGames::Resource.

Definition at line 102 of file Texture.cpp.

◆ WritePixels()

void AeonGames::Texture::WritePixels ( int32_t aXOffset,
int32_t aYOffset,
uint32_t aWidth,
uint32_t aHeight,
Format aFormat,
Type aType,
const uint8_t * aPixels )

Writes pixel data into a sub-region of the texture.

Parameters
aXOffsetHorizontal offset in pixels.
aYOffsetVertical offset in pixels.
aWidthWidth of the region to write.
aHeightHeight of the region to write.
aFormatPixel format of the source data.
aTypePixel type of the source data.
aPixelsPointer to the source pixel data.
Todo
Implement format-type translation.

Definition at line 63 of file Texture.cpp.


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