nCine::ITextureLoader class

Texture loader interface class.

Common base for all texture file loaders. Decodes a texture file into raw pixel data together with its dimensions, pixel format and MIP map chain, ready to be uploaded to the GPU by Texture. Concrete subclasses handle individual file formats and are instantiated through the createFromFile() factory according to the file extension.

Derived classes

class TextureLoaderDds
Texture loader for the DirectDraw Surface (.dds) format.
class TextureLoaderKtx
Texture loader for the Khronos Texture (.ktx) format.
class TextureLoaderPkm
Texture loader for the ETC1 PKM (.pkm) format.
class TextureLoaderPng
Texture loader for the Portable Network Graphics (.png) format.
class TextureLoaderPvr
Texture loader for the PowerVR (.pvr) format.
class TextureLoaderQoi
Texture loader for the Quite OK Image (.qoi) format.
class TextureLoaderRaw
Texture loader that describes an empty raw-format texture.

Public static functions

static auto createFromFile(const Death::Containers::StringView filename) -> std::unique_ptr<ITextureLoader>
Returns the proper texture loader according to the file extension.

Constructors, destructors, conversion operators

~ITextureLoader() virtual
ITextureLoader() protected
An empty constructor only used by TextureLoaderRaw.
ITextureLoader(std::unique_ptr<Death::IO::Stream> fileHandle) protected explicit

Public functions

auto hasLoaded() const -> bool
Returns true if the texture has been correctly loaded.
auto width() const -> std::int32_t
Returns texture width in pixels.
auto height() const -> std::int32_t
Returns texture height in pixels.
auto size() const -> Vector2i
Returns texture size as a Vector2i.
auto mipMapCount() const -> std::int32_t
Returns the number of MIP maps stored in the texture file.
auto dataSize() const -> std::uint32_t
Returns texture data size in bytes.
auto dataSize(std::uint32_t mipMapLevel) const -> std::int32_t
Returns the texture data size in bytes for the specified MIP map level.
auto texFormat() const -> const TextureFormat&
Returns the texture format object.
auto pixels() const -> const GLubyte*
Returns the pointer to pixel data.
auto pixels(std::uint32_t mipMapLevel) const -> const GLubyte*
Returns the pointer to pixel data for the specified MIP map level.

Protected static functions

static auto createLoader(std::unique_ptr<Death::IO::Stream> fileHandle, const Death::Containers::StringView path) -> std::unique_ptr<ITextureLoader>

Protected functions

void loadPixels(GLenum internalFormat)
Loads pixel data from a texture file holding either compressed or uncompressed data.
void loadPixels(GLenum internalFormat, GLenum type)
Loads pixel data from a texture file holding either compressed or uncompressed data, overriding pixel type.

Function documentation

static std::unique_ptr<ITextureLoader> nCine::ITextureLoader::createFromFile(const Death::Containers::StringView filename)

Returns the proper texture loader according to the file extension.

Parameters
filename Path of the texture file to load

std::int32_t nCine::ITextureLoader::dataSize(std::uint32_t mipMapLevel) const

Returns the texture data size in bytes for the specified MIP map level.

Parameters
mipMapLevel Zero-based MIP map level

const GLubyte* nCine::ITextureLoader::pixels(std::uint32_t mipMapLevel) const

Returns the pointer to pixel data for the specified MIP map level.

Parameters
mipMapLevel Zero-based MIP map level

void nCine::ITextureLoader::loadPixels(GLenum internalFormat) protected

Loads pixel data from a texture file holding either compressed or uncompressed data.

Parameters
internalFormat OpenGL internal format describing the decoded pixels

void nCine::ITextureLoader::loadPixels(GLenum internalFormat, GLenum type) protected

Loads pixel data from a texture file holding either compressed or uncompressed data, overriding pixel type.

Parameters
internalFormat OpenGL internal format describing the decoded pixels
type OpenGL pixel type that overrides the format default