ASGE  3.2.0
Simple Game Framework in GL
ASGE::Texture2D Class Referenceabstract

#include <Texture.hpp>

Public Types

enum  Format { MONOCHROME = 1 , MONOCHROME_ALPHA = 2 , RGB = 3 , RGBA = 4 }
 
enum class  MinFilter : uint32_t {
  LINEAR , LINEAR_MIPMAP_NEAREST , LINEAR_MIPMAP_LINEAR , NEAREST ,
  NEAREST_MIPMAP_LINEAR , NEAREST_MIPMAP_NEAREST
}
 
enum class  UVWrapMode { CLAMP , REPEAT , MIRRORED }
 
using MagFilter = GameSettings::MagFilter
 

Public Member Functions

 Texture2D (int width, int height) noexcept
 
virtual ~Texture2D ()=default
 
void setFormat (Format f) noexcept
 
Format getFormat () const
 
virtual void updateMagFilter (MagFilter filter)=0
 
virtual void updateMinFilter (MinFilter filter)=0
 
virtual void updateUVWrapping (UVWrapMode s, UVWrapMode t)=0
 
virtual void updateMips ()=0
 
virtual PixelBuffergetPixelBuffer () noexcept=0
 
virtual const PixelBuffergetPixelBuffer () const noexcept=0
 
float getWidth () const noexcept
 
float getHeight () const noexcept
 

Detailed Description

a simple 2D non-renderable texture.

A texture is used to load images into the GPU. They retain a handle or link to it and the renderers are free to implement any caching systems they see fit.

Definition at line 56 of file Texture.hpp.

Member Typedef Documentation

◆ MagFilter

< Shorthand for MagFilter

Definition at line 61 of file Texture.hpp.

Member Enumeration Documentation

◆ Format

The format of the texture

Enumerator
MONOCHROME 

The texture is monochromatic.

MONOCHROME_ALPHA 

The texture is monochromatic and has an alpha channel.

RGB 

There are Red, Green & Blue channels present.

RGBA 

There are RGB plus alpha channels present .

Definition at line 66 of file Texture.hpp.

◆ MinFilter

enum ASGE::Texture2D::MinFilter : uint32_t
strong

Min filters used when scaling textures downwards

Definition at line 77 of file Texture.hpp.

◆ UVWrapMode

modes that controlling the UV texture wrapping

When sampling textures and using UV coordinates outside of the normalised range, wrapping modes can be used to control the resultant sampled pixel. For example, REPEAT will continuously wrap the texture. This is good for when you want to sample outside the normal [0,1] range but still obtain a resultant pixel. A use case for this is a scrolling background layer.

Enumerator
CLAMP 

Clamps the texture to [0,1].

REPEAT 

Repeats the texture.

MIRRORED 

Mirrors the image with each repeat.

Definition at line 98 of file Texture.hpp.

Constructor & Destructor Documentation

◆ Texture2D()

ASGE::Texture2D::Texture2D ( int  width,
int  height 
)
inlinenoexcept

Default constructor.

Parameters
widthThe width of the texture.
heightthe height of the texture.

Definition at line 110 of file Texture.hpp.

◆ ~Texture2D()

virtual ASGE::Texture2D::~Texture2D ( )
virtualdefault

Default destructor. The destructor does not free the memory used on the GPU. This is handled inside the platform's specific implementation.

Member Function Documentation

◆ getFormat()

Format ASGE::Texture2D::getFormat ( ) const
inline

Retrieves the format of the stored texture.

Returns
The format of the texture.
See also
Format

Definition at line 135 of file Texture.hpp.

◆ getHeight()

float ASGE::Texture2D::getHeight ( ) const
inlinenoexcept

Retrieves the width of the loaded texture.

Returns
The height of the texture.

Definition at line 198 of file Texture.hpp.

◆ getPixelBuffer() [1/2]

virtual const PixelBuffer* ASGE::Texture2D::getPixelBuffer ( ) const
pure virtualnoexcept

Retrieves the texture from GPU memory. Retrieving memory from the GPU like this is a slow process. It is best to do this infrequently.

Returns
The binary file loaded in memory.

◆ getPixelBuffer() [2/2]

virtual PixelBuffer* ASGE::Texture2D::getPixelBuffer ( )
pure virtualnoexcept

Retrieves the texture from GPU memory. Retrieving memory from the GPU like this is a slow process. It is best to do this infrequently.

Returns
The binary file loaded in memory.

◆ getWidth()

float ASGE::Texture2D::getWidth ( ) const
inlinenoexcept

Retrieves the width of the loaded texture.

Returns
The width of the texture.

Definition at line 192 of file Texture.hpp.

◆ setFormat()

void ASGE::Texture2D::setFormat ( Format  f)
inlinenoexcept

Sets the format of the texture.

Parameters
fThe format of the stored texture.
See also
Format

Definition at line 128 of file Texture.hpp.

◆ updateMagFilter()

virtual void ASGE::Texture2D::updateMagFilter ( MagFilter  filter)
pure virtual
Sets the filtering used for texture magnification.
Allows the type of filtering applied when

sampling the texture under magnification to be changed.

Parameters
filterThe magnification filter to apply.

◆ updateMinFilter()

virtual void ASGE::Texture2D::updateMinFilter ( MinFilter  filter)
pure virtual
Sets the filtering used for texture minification.
Allows the type of filtering applied when

sampling the texture under minification to be changed.

Parameters
filterThe minification filter to apply.

◆ updateMips()

virtual void ASGE::Texture2D::updateMips ( )
pure virtual

Rebuilds the mip maps used for minification.

◆ updateUVWrapping()

virtual void ASGE::Texture2D::updateUVWrapping ( UVWrapMode  s,
UVWrapMode  t 
)
pure virtual

Controls how the UV coordinates are wrapped.

When sampling the texture, UV coordinates outside of the range of [0,1] can either be clamped or repeated. It is also possible to clamp in one direction, and repeat in another as both directions (s,t) can be controlled independently of each other.

Parameters
sThe wrapping mode for the x dimension.
tThe wrapping mode for the y dimension.

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