![]() |
nCine
2025.04.r498-9d36345
A cross-platform 2D game engine
|
#include <Texture.h>
Public Types | |
enum class | Format { R8 , RG8 , RGB8 , RGBA8 , UNKNOWN } |
Texture formats. | |
enum class | Filtering { NEAREST , LINEAR , NEAREST_MIPMAP_NEAREST , LINEAR_MIPMAP_NEAREST , NEAREST_MIPMAP_LINEAR , LINEAR_MIPMAP_LINEAR } |
Texture filtering modes. | |
enum class | Wrap { CLAMP_TO_EDGE , MIRRORED_REPEAT , REPEAT } |
Texture wrap modes. | |
![]() | |
enum class | ObjectType { BASE = 0 , TEXTURE , SHADER , SCENENODE , SPRITE , MESH_SPRITE , ANIMATED_SPRITE , PARTICLE , PARTICLE_SYSTEM , FONT , TEXTNODE , AUDIOBUFFER , AUDIOBUFFER_PLAYER , AUDIOSTREAM_PLAYER } |
Object types. | |
Public Member Functions | |
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. More... | |
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. More... | |
Texture (const char *name, Format format, int width, int height) | |
Creates an empty texture with the specified format and size. More... | |
Texture (const char *name, Format format, Vector2i size) | |
Creates an empty texture with the specified format and size using a vector. More... | |
Texture (const char *bufferName, const unsigned char *bufferPtr, unsigned long int bufferSize) | |
Creates a texture from a named memory buffer. More... | |
Texture (const char *filename) | |
Creates a texture from an image file. | |
Texture (Texture &&) | |
Default move constructor. | |
Texture & | operator= (Texture &&) |
Default move assignment operator. | |
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. | |
bool | loadFromMemory (const char *bufferName, const unsigned char *bufferPtr, unsigned long int bufferSize) |
bool | loadFromFile (const char *filename) |
bool | loadFromTexels (const unsigned char *bufferPtr) |
Loads all texture texels in raw format from a memory buffer in the first mip level. More... | |
bool | loadFromTexels (const unsigned char *bufferPtr, unsigned int x, unsigned int y, unsigned int width, unsigned int height) |
Loads texels in raw format from a memory buffer to a texture sub-region in the first mip level. More... | |
bool | loadFromTexels (const unsigned char *bufferPtr, Recti region) |
Loads texels in raw format from a memory buffer to a texture sub-region with a rectangle in the first mip level. More... | |
bool | loadFromTexels (const unsigned char *bufferPtr, unsigned int level, unsigned int x, unsigned int y, unsigned int width, unsigned int height) |
Loads texels in raw format from a memory buffer to a specific texture mip level and sub-region. More... | |
bool | loadFromTexels (const unsigned char *bufferPtr, unsigned int level, Recti region) |
Loads texels in raw format from a memory buffer to a specific texture mip level and sub-region with a rectangle. More... | |
bool | saveToMemory (unsigned char *bufferPtr) |
Saves all texture texels in the first mip level in raw format to a memory buffer. | |
bool | saveToMemory (unsigned char *bufferPtr, unsigned int level) |
Saves all texture texels in the specified texture mip level in raw format to a memory buffer. | |
int | width () const |
Returns texture width. | |
int | height () const |
Returns texture height. | |
int | mipMapLevels () const |
Returns texture MIP map levels. | |
Vector2i | size () const |
Returns texture size. | |
Recti | rect () const |
Returns texture rectangle. | |
bool | isCompressed () const |
Returns true if the texture holds compressed data. | |
Format | format () const |
Returns the texture data format. | |
unsigned int | numChannels () const |
Returns the number of color channels. | |
unsigned long | dataSize () const |
Returns the amount of video memory needed to load the texture. | |
Filtering | minFiltering () const |
Returns the texture filtering for minification. | |
Filtering | magFiltering () const |
Returns the texture filtering for magnification. | |
Wrap | wrap () const |
Returns texture wrap for both s and t coordinates. | |
void | setMinFiltering (Filtering filter) |
Sets the texture filtering for minification. | |
void | setMagFiltering (Filtering filter) |
Sets the texture filtering for magnification. | |
void | setWrap (Wrap wrapMode) |
Sets texture wrap for both s and t coordinates. | |
bool | isChromaKeyEnabled () const |
Returns true if chroma key transparency will be used when loading. | |
Color | chromaKeyColor () const |
Returns the color treated as transparent when loading a texture. | |
void | setChromaKeyEnabled (bool chromaKeyEnabled) |
Sets the chroma key transparency state to use when loading. | |
void | setChromaKeyColor (const Color &chromaKeyColor) |
Sets the color to be treated as transparent when loading a texture. | |
void | setChromaKeyColor (const Colorf &chromaKeyColor) |
Sets the color to be treated as transparent when loading a texture, using a Colorf | |
void | setGLTextureLabel (const char *label) |
Sets the OpenGL object label for the texture. | |
void * | guiTexId () const |
Returns the user data opaque pointer for ImGui's ImTextureID or Nuklear's texture handle. More... | |
![]() | |
Object (ObjectType type) | |
Constructs an object with a specified type and adds it to the index. | |
Object (ObjectType type, const char *name) | |
Constructs an object with a specified type and name and adds it to the index. | |
virtual | ~Object () |
Removes an object from the index and then destroys it. | |
Object (Object &&other) | |
Move constructor. | |
Object & | operator= (Object &&other) |
Move assignment operator. | |
unsigned int | id () const |
Returns the object identification number. | |
ObjectType | type () const |
Returns the object type (RTTI) | |
const char * | name () const |
Returns the object name. | |
void | setName (const char *name) |
Sets the object name. | |
Static Public Member Functions | |
static ObjectType | sType () |
![]() | |
static ObjectType | sType () |
Static method to return class type. | |
template<class T > | |
static T * | fromId (unsigned int id) |
Returns a casted pointer to the object with the specified id, if any exists. | |
Friends | |
class | Material |
class | Viewport |
Additional Inherited Members | |
![]() | |
static const unsigned int | MaxNameLength = 128 |
Maximum length for an object name. | |
![]() | |
Object (const Object &other) | |
Protected copy constructor used to clone objects. | |
![]() | |
ObjectType | type_ |
Object type. | |
Texture class.
ncine::Texture::Texture | ( | const char * | name, |
Format | format, | ||
int | mipMapCount, | ||
int | width, | ||
int | height | ||
) |
Creates an empty texture with the specified format, MIP levels, and size.
loadFromTexels()
Creates an empty texture with the specified format, MIP levels, and size using a vector.
loadFromTexels()
ncine::Texture::Texture | ( | const char * | name, |
Format | format, | ||
int | width, | ||
int | height | ||
) |
Creates an empty texture with the specified format and size.
loadFromTexels()
Creates an empty texture with the specified format and size using a vector.
loadFromTexels()
ncine::Texture::Texture | ( | const char * | bufferName, |
const unsigned char * | bufferPtr, | ||
unsigned long int | bufferSize | ||
) |
Creates a texture from a named memory buffer.
bufferName
with a valid file extension as it loads compressed data from a file in memory void * ncine::Texture::guiTexId | ( | ) | const |
Returns the user data opaque pointer for ImGui's ImTextureID
or Nuklear's texture handle.
The pointer is an opaque handle to be used only by ImGui or Nuklear. It is considered immutable from an user point of view and thus retrievable by a constant method.
bool ncine::Texture::loadFromMemory | ( | const char * | bufferName, |
const unsigned char * | bufferPtr, | ||
unsigned long int | bufferSize | ||
) |
bufferName
with a valid file extension as it loads compressed data from a file in memory bool ncine::Texture::loadFromTexels | ( | const unsigned char * | bufferPtr | ) |
Loads all texture texels in raw format from a memory buffer in the first mip level.
Format
specified in the constructor bool ncine::Texture::loadFromTexels | ( | const unsigned char * | bufferPtr, |
Recti | region | ||
) |
Loads texels in raw format from a memory buffer to a texture sub-region with a rectangle in the first mip level.
Format
specified in the constructor bool ncine::Texture::loadFromTexels | ( | const unsigned char * | bufferPtr, |
unsigned int | level, | ||
Recti | region | ||
) |
Loads texels in raw format from a memory buffer to a specific texture mip level and sub-region with a rectangle.
It loads uncompressed pixel data from memory using the Format
specified in the constructor
bool ncine::Texture::loadFromTexels | ( | const unsigned char * | bufferPtr, |
unsigned int | level, | ||
unsigned int | x, | ||
unsigned int | y, | ||
unsigned int | width, | ||
unsigned int | height | ||
) |
Loads texels in raw format from a memory buffer to a specific texture mip level and sub-region.
Format
specified in the constructor bool ncine::Texture::loadFromTexels | ( | const unsigned char * | bufferPtr, |
unsigned int | x, | ||
unsigned int | y, | ||
unsigned int | width, | ||
unsigned int | height | ||
) |
Loads texels in raw format from a memory buffer to a texture sub-region in the first mip level.
Format
specified in the constructor