nCine::Texture class

Texture.

Base classes

class Object
Base class of nCine objects.

Public types

enum class Format { Unknown, R8, RG8, RGB8, RGBA8 }
Texture formats.

Public static functions

static auto sType() -> ObjectType

Constructors, destructors, conversion operators

Texture()
Creates an OpenGL texture name.
Texture(const char* name, Format format, int mipMapCount, int width, int height)
Creates an empty texture with the specified format, MIP levels, and size.
Texture(const char* name, Format format, int mipMapCount, Vector2i size)
Creates an empty texture with the specified format, MIP levels, and size using a vector.
Texture(const char* name, Format format, int width, int height)
Creates an empty texture with the specified format and size.
Texture(const char* name, Format format, Vector2i size)
Creates an empty texture with the specified format and size using a vector.
Texture(StringView filename) explicit
Creates a texture from an image file.
~Texture() override
Texture(const Texture&) deleted
Texture(Texture&&)

Public functions

auto operator=(const Texture&) -> Texture& deleted
auto operator=(Texture&&) -> Texture&
void init(const char* name, Format format, int mipMapCount, int width, int height)
Initializes an empty texture with the specified format, MIP levels, and size.
void init(const char* name, Format format, int mipMapCount, Vector2i size)
Initializes an empty texture with the specified format, MIP levels, and size using a vector.
void init(const char* name, Format format, int width, int height)
Initializes an empty texture with the specified format and size.
void init(const char* name, Format format, Vector2i size)
Initializes an empty texture with the specified format and size using a vector.
auto loadFromFile(StringView filename) -> bool
auto loadFromTexels(const unsigned char* bufferPtr) -> bool
Loads all texture texels in raw format from a memory buffer in the first mip level.
auto loadFromTexels(const unsigned char* bufferPtr, unsigned int x, unsigned int y, unsigned int width, unsigned int height) -> bool
Loads texels in raw format from a memory buffer to a texture sub-region in the first mip level.
auto loadFromTexels(const unsigned char* bufferPtr, Recti region) -> bool
Loads texels in raw format from a memory buffer to a texture sub-region with a rectangle in the first mip level.
auto loadFromTexels(const unsigned char* bufferPtr, unsigned int level, unsigned int x, unsigned int y, unsigned int width, unsigned int height) -> bool
Loads texels in raw format from a memory buffer to a specific texture mip level and sub-region.
auto loadFromTexels(const unsigned char* bufferPtr, unsigned int level, Recti region) -> bool
Loads texels in raw format from a memory buffer to a specific texture mip level and sub-region with a rectangle.
auto saveToMemory(unsigned char* bufferPtr) -> bool
Saves all texture texels in the first mip level in raw format to a memory buffer.
auto saveToMemory(unsigned char* bufferPtr, unsigned int level) -> bool
Saves all texture texels in the specified texture mip level in raw format to a memory buffer.
auto width() const -> int
Returns texture width.
auto height() const -> int
Returns texture height.
auto mipMapLevels() const -> int
Returns texture MIP map levels.
auto size() const -> Vector2i
Returns texture size.
auto rect() const -> Recti
Returns texture rectangle.
auto isCompressed() const -> bool
Returns true if the texture holds compressed data.
auto numChannels() const -> unsigned int
Returns the number of color channels.
auto dataSize() const -> unsigned long
Returns the amount of video memory needed to load the texture.
auto minFiltering() const -> SamplerFilter
Returns the texture filtering for minification.
auto magFiltering() const -> SamplerFilter
Returns the texture filtering for magnification.
auto wrap() const -> SamplerWrapping
Returns texture wrap for both s and t coordinates.
void setMinFiltering(SamplerFilter filter)
Sets the texture filtering for minification.
void setMagFiltering(SamplerFilter filter)
Sets the texture filtering for magnification.
void setWrap(SamplerWrapping wrapMode)
Sets texture wrap for both s and t coordinates.
void setGLTextureLabel(const char* label)
Sets the OpenGL object label for the texture.
auto guiTexId() const -> void*
Returns the user data opaque pointer for ImGui's ImTextureID