nCine::MeshSprite class

A scene node representing a mesh with vertices and UVs.

Base classes

class BaseSprite
Base class for sprites.

Public types

struct Vertex
Vertex data for the mesh.
struct VertexNoTexture
Vertex data for the mesh when no texture is specified.
enum class TextureCutMode { RESIZE, CROP }

Public static variables

static const unsigned int VertexBytes
static const unsigned int VertexFloats
static const unsigned int VertexNoTextureBytes
static const unsigned int VertexNoTextureFloats

Public static functions

static auto sType() -> ObjectType

Constructors, destructors, conversion operators

MeshSprite()
Default constructor for a sprite with no parent and no texture, positioned in the origin.
MeshSprite(SceneNode* parent, Texture* texture)
Constructor for a sprite with a parent and texture, positioned in the relative origin.
MeshSprite(Texture* texture) explicit
Constructor for a sprite with a texture but no parent, positioned in the origin.
MeshSprite(SceneNode* parent, Texture* texture, float xx, float yy)
Constructor for a sprite with a parent, a texture and a specified relative position.
MeshSprite(SceneNode* parent, Texture* texture, Vector2f position)
Constructor for a sprite with a parent, a texture and a specified relative position as a vector.
MeshSprite(Texture* texture, float xx, float yy)
Constructor for a sprite with a texture and a specified position but no parent.
MeshSprite(Texture* texture, Vector2f position)
Constructor for a sprite with a texture and a specified position as a vector but no parent.
MeshSprite(MeshSprite&&) defaulted
MeshSprite(const MeshSprite& other) protected
Protected copy constructor used to clone objects.

Public functions

auto operator=(MeshSprite&&) -> MeshSprite& defaulted
auto clone() const -> MeshSprite
Returns a copy of this object.
auto bytesPerVertex() const -> unsigned int
Returns the number of bytes used by each vertex.
auto numVertices() const -> unsigned int
Returns the number of vertices of the sprite mesh.
auto numBytes() const -> unsigned int
Returns the total number of bytes used by all sprite's vertices.
auto vertices() const -> const float*
Returns the vertices data of the sprite mesh.
auto uniqueVertices() const -> bool
Returns true if the vertices belong to the sprite and are not stored externally.
void copyVertices(unsigned int numVertices, unsigned int bytesPerVertex, const void* vertexData)
Copies the vertices data with a custom format from a pointer into the sprite.
void copyVertices(unsigned int numVertices, const Vertex* vertices)
Copies the vertices data from a pointer into the sprite.
void copyVertices(unsigned int numVertices, const VertexNoTexture* vertices)
Copies the vertices data from a pointer into the sprite (no texture version)
void copyVertices(const MeshSprite& meshSprite)
Copies the vertices data from another sprite and sets the same size.
void setVertices(unsigned int numVertices, unsigned int bytesPerVertex, const void* vertexData)
Sets the vertices data to point to an external array with a custom format.
void setVertices(unsigned int numVertices, const Vertex* vertices)
Sets the vertices data to point to an external array.
void setVertices(unsigned int numVertices, const VertexNoTexture* vertices)
Sets the vertices data to point to an external array (no texture version)
void setVertices(const MeshSprite& meshSprite)
Sets the vertices data to the data used by another sprite and sets the same size.
auto emplaceVertices(unsigned int numElements, unsigned int bytesPerVertex) -> float*
Returns the internal vertices data, cleared and set to the required size (custom format version)
auto emplaceVertices(unsigned int numElements) -> float*
Returns the internal vertices data, cleared and set to the required size.
void createVerticesFromTexels(unsigned int numVertices, const Vector2f* points, TextureCutMode cutMode)
Creates an internal set of vertices from an external array of points in texture space, with optional texture cut mode.
void createVerticesFromTexels(unsigned int numVertices, const Vector2f* points)
Creates an internal set of vertices from an external array of points in texture space.
auto numIndices() const -> unsigned int
Returns the number of indices used to draw the sprite mesh.
auto indices() const -> const unsigned short*
Returns the indices used to draw the sprite mesh.
auto uniqueIndices() const -> bool
Returns true if the indices belong to the sprite and are not stored externally.
void copyIndices(unsigned int numIndices, const unsigned short* indices)
Copies the indices from a pointer into the sprite.
void copyIndices(const MeshSprite& meshSprite)
Copies the indices from another sprite.
void setIndices(unsigned int numIndices, const unsigned short* indices)
Sets the indices data to point to an external array.
void setIndices(const MeshSprite& meshSprite)
Sets the indices data to the data used by another sprite.
auto emplaceIndices(unsigned int numIndices) -> unsigned short*
Returns the internal indices data, cleared and set to the required size.

Private functions

void shaderHasChanged() override
Performs the required tasks upon a change to the shader.
void textureHasChanged(Texture* newTexture) override
Performs the required tasks upon a change to the texture.