Sprite

High-level sprite handling utilities.

Overview

Typical use cases:

  • Managing sprite instances and rendering.

Header

<RaeptorCogs/Sprite.hpp>

Metadata

Author

Estorc

Version

v1.0

Copyright

Copyright (c) 2025 Estorc MIT License.

Classes

Classes

Class

Description

RaeptorCogs::Sprite2D

Class representing a 2D sprite.

class Sprite2D : public RaeptorCogs::TransformableGraphic2D

Class representing a 2D sprite.

Manages texture and rendering for a 2D sprite. Inherits from TransformableGraphic2D to provide transformation capabilities.

Public Functions

Sprite2D(Texture &texture)

Constructor for Sprite2D with a texture.

Parameters:

textureTexture to associate with the sprite.

inline Sprite2D()

Default constructor for Sprite2D.

~Sprite2D() = default

Destructor for Sprite2D.

virtual bool computeInstanceData(GAPI::Common::InstanceAllocator &instanceAllocator, ComputeInstanceDataMode mode = ComputeInstanceDataMode::NONE) override

Compute instance data for the sprite.

Parameters:
  • instanceAllocator – Reference to the instance allocator.

  • mode – Mode for computing instance data.

Returns:

true if updates were made, false otherwise.

virtual void bind() const override

Bind the sprite for rendering.

Note

Overrides the bind method from Graphic2D.

virtual GLuint getID() const override

Get the unique ID of the sprite.

Returns:

Unique ID of the sprite.

virtual bool isOpaque() const override

Check if the sprite is opaque.

Returns:

true if the sprite is opaque, false otherwise.

virtual bool isVisible() const override

Check if the sprite is visible.

Returns:

true if the sprite is visible, false otherwise.

virtual Texture getTexture() const override

Get the texture associated with the sprite.

Returns:

Texture associated with the sprite.

void setTexture(Texture &texture)

Set the texture associated with the sprite.

Parameters:

textureTexture to associate with the sprite.

Private Members

Texture texture = nullptr

Texture associated with the sprite.

Holds the texture used for rendering the sprite.

Note

Initialized to nullptr.