Skip to content

Texture

Abstract base class for texture types.

This class is not intended to be used directly. Use one of the concrete texture types such as Texture2D, or derive your own texture class that implements the required interface.

Types

Texture::ColorSpace enum

Enumerates supported color spaces for texture sampling.

Textures containing color data (e.g. albedo or base color maps) are typically authored in sRGB and should use ColorSpace::sRGB. Data textures (e.g. normals, roughness, metallic, masks) must use ColorSpace::Linear to preserve numerical correctness.

ValueDescription
LinearLinear color space, no gamma correction is applied.
sRGBsRGB color space, converted to linear on sampling.

Texture::Format enum

Enumerates pixel format and storage type for the texture.

ValueDescription
RGBA88-bit normalized RGBA.
RGBA16F16-bit float RGBA.
R16F16-bit float single channel.
R32F32-bit float single channel.
R32UI32-bit unsigned integer single channel.
SRGBA88-bit sRGB-encoded RGBA.

Texture::MagFilter enum

Enumerates supported magnification filters.

Magnification filters control how a texture is sampled when it is rendered larger than its native resolution.

ValueDescription
NearestNearest-neighbor sampling.
LinearLinear interpolation.

Texture::Mapping enum

Enumerates supported texture mapping modes.

Mapping describes how the texture's content should be interpreted when sampled rather than how it is stored. A 2D texture marked as

Mapping::Equirectangular holds a full 360° panorama (e.g. an HDR environment) and is sampled by direction instead of texture coordinates.

ValueDescription
UVSampled with texture coordinates (default).
EquirectangularPanorama sampled by direction.

Texture::MinFilter enum

Enumerates supported minification filters.

Minification filters control how a texture is sampled when it is rendered smaller than its native resolution. Mipmapped filters select and blend between mip levels when available.

ValueDescription
NearestNearest-neighbor sampling.
LinearLinear interpolation.
NearestMipmapNearestNearest mip, nearest sample.
LinearMipmapNearestNearest mip, linear sample.
NearestMipmapLinearLinear mip, nearest sample.
LinearMipmapLinearLinear mip, linear sample.

Texture::RowAlignment enum

Specifies the byte alignment of each row in source texture data.

Determines how pixel rows are aligned in memory when uploading texture data to the GPU. The alignment value must match the source image’s row stride to ensure correct decoding and avoid visual artifacts.

RGBA8 textures typically use 4-byte row alignment.

ValueDescription
OneByte1-byte alignment (tightly packed).
TwoBytes2-byte alignment.
FourBytes4-byte alignment (default).
EightBytes8-byte alignment.

Texture::Type enum

Enumerates all supported texture types.

ValueDescription
Texture2DTwo-dimensional texture.
DynamicTexture2DTwo-dimensional dynamic GPU texture.
CubeTextureCube texture made up of six images.

Texture::Wrapping enum

Enumerates supported texture wrapping modes.

Wrapping modes control how a texture is sampled when texture coordinates fall outside the range, applied independently per axis.

Cube maps ignore these modes and always clamp to edge to avoid visible seams where faces meet.

ValueDescription
RepeatTiles the texture, ignoring the integer part of the coordinate.
ClampToEdgeClamps the coordinate to the edge texel.
MirroredRepeatTiles the texture, mirroring on each repetition.

Properties

anisotropy float

Maximum anisotropy used when sampling this texture. Values greater than 1 enable anisotropic filtering, which improves texture quality at oblique viewing angles. The value is clamped to the driver-reported maximum at upload time. Only takes effect when the texture is sampled with a mipmapped minification filter. Defaults to 1 (isotropic).

cpp
float anisotropy {1.0f};

color_space ColorSpace

Color space used when sampling this texture.

cpp
ColorSpace color_space {ColorSpace::sRGB};

format Format

Texture storage format.

cpp
Format format {Format::RGBA8};

generate_mipamps bool

Enables automatic mipmap generation for this texture.

cpp
bool generate_mipamps {false};

mag_filter MagFilter

Magnification filter used when sampling the texture.

cpp
MagFilter mag_filter {MagFilter::Linear};

mapping Mapping

Mapping mode used to interpret the texture's content.

cpp
Mapping mapping {Mapping::UV};

min_filter MinFilter

Minification filter used when sampling the texture.

cpp
MinFilter min_filter {MinFilter::Linear};

renderer_id unsigned int

Renderer-specific texture handle. Typically corresponds to the underlying graphics API object identifier, for example, an OpenGL texture ID.

cpp
unsigned int renderer_id {0};

row_alignment RowAlignment

Row alignment used when uploading texture data.

cpp
RowAlignment row_alignment {RowAlignment::FourBytes};

wrap_s Wrapping

Wrapping mode applied to the horizontal (U) texture coordinate.

cpp
Wrapping wrap_s {Wrapping::Repeat};

wrap_t Wrapping

Wrapping mode applied to the vertical (V) texture coordinate.

cpp
Wrapping wrap_t {Wrapping::Repeat};

Functions

GetType() Type pure virtual

Identifies the concrete texture type.

cpp
virtual Type Texture::GetType() const=0;

Released under the MIT License.