16#ifndef AEONGAMES_TEXTURE_H
17#define AEONGAMES_TEXTURE_H
23#include "aeongames/Resource.hpp"
76 DLL
void WritePixels ( int32_t aXOffset, int32_t aYOffset, uint32_t aWidth, uint32_t aHeight,
Format aFormat,
Type aType,
const uint8_t* aPixels );
81 DLL
void LoadFromMemory (
const void* aBuffer,
size_t aBufferSize )
final;
95 std::vector<uint8_t> mPixels{};
108 DLL
bool RegisterImageDecoder (
const std::string& aMagick,
const std::function <
bool (
Texture&,
size_t,
const void* ) > & aDecoder );
Base class for loadable engine resources.
Represents a 2D texture image resource.
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 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 Format GetFormat() const
Returns the pixel format.
DLL const std::vector< uint8_t > & GetPixels() const
Returns a reference to the raw pixel data.
Type
Pixel component data type.
@ UNSIGNED_INT_8_8_8_8_REV
Packed 32-bit unsigned integer with reversed byte order.
@ UNSIGNED_SHORT
16-bit unsigned integer per channel.
@ Unknown
Unspecified or invalid type.
@ UNSIGNED_BYTE
8-bit unsigned integer per channel.
DLL ~Texture()
Destructor.
Format
Pixel channel layout format.
@ BGRA
4-channel blue, green, red, alpha.
@ Unknown
Unspecified or invalid format.
@ RGB
3-channel red, green, blue.
@ RGBA
4-channel red, green, blue, alpha.
DLL Type GetType() const
Returns the pixel component type.
DLL void LoadFromMemory(const void *aBuffer, size_t aBufferSize) final
Loads texture data from a raw memory buffer.
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 uint32_t GetHeight() const
Returns the texture height in pixels.
<- This is here just for the literals
DLL bool RegisterImageDecoder(const std::string &aMagick, const std::function< bool(Texture &, size_t, const void *) > &aDecoder)
Registers an image decoder for a specific file magic identifier.
DLL bool UnregisterImageDecoder(const std::string &aMagick)
Unregisters a previously registered image decoder.
DLL bool DecodeImage(Texture &aTexture, const void *aBuffer, size_t aBufferSize)
Decodes image data from a memory buffer into a Texture.