libdonut  2.3.2
Application framework for cross-platform game development in C++20
Public Attributes | List of all members
donut::graphics::SpriteInstance Struct Reference

Configuration of a 2D sprite instance from a SpriteAtlas, for drawing as part of a RenderPass. More...

#include <donut/graphics/RenderPass.hpp>

Public Attributes

Shader2Dshader = Shader2D::PLAIN
 Non-owning pointer to the shader to use when rendering this sprite. More...
 
const SpriteAtlasatlas
 Non-owning pointer to the texture atlas in which the sprite resides. More...
 
SpriteAtlas::SpriteId id
 Identifier of the specific sprite in the SpriteInstance::atlas that is to be drawn. More...
 
vec2 position {0.0f, 0.0f}
 Position, in world coordinates, to render the sprite at, with respect to its SpriteInstance::origin. More...
 
vec2 scale {1.0f, 1.0f}
 Coefficients to scale the size of the sprite by. More...
 
float angle = 0.0f
 Angle, in radians, to rotate the sprite by, around its SpriteInstance::origin. More...
 
vec2 origin {0.0f, 0.0f}
 Offset, in texture coordinates, specifying the origin relative to the bottom left of the sprite. More...
 
Color tintColor = Color::WHITE
 Tint color to use in the shader. More...
 

Detailed Description

Configuration of a 2D sprite instance from a SpriteAtlas, for drawing as part of a RenderPass.

Required fields:

Note
Consecutive sprite instances with the same shader and atlas will be batched and rendered together.
See also
QuadInstance
TextureInstance
RectangleInstance
Examples
example_game.cpp.

Member Data Documentation

◆ shader

Shader2D* donut::graphics::SpriteInstance::shader = Shader2D::PLAIN

Non-owning pointer to the shader to use when rendering this sprite.

Warning
The pointed-to shader must remain valid for the duration of its use in the RenderPass, and must not be nullptr.

◆ atlas

const SpriteAtlas* donut::graphics::SpriteInstance::atlas

Non-owning pointer to the texture atlas in which the sprite resides.

Warning
The pointed-to atlas must remain valid for the duration of its use in the RenderPass, and must not be nullptr.
Examples
example_game.cpp.

◆ id

SpriteAtlas::SpriteId donut::graphics::SpriteInstance::id

Identifier of the specific sprite in the SpriteInstance::atlas that is to be drawn.

Warning
Must be a valid sprite identifier obtained from the SpriteAtlas pointed to by SpriteInstance::atlas.

◆ position

vec2 donut::graphics::SpriteInstance::position {0.0f, 0.0f}

Position, in world coordinates, to render the sprite at, with respect to its SpriteInstance::origin.

◆ scale

vec2 donut::graphics::SpriteInstance::scale {1.0f, 1.0f}

Coefficients to scale the size of the sprite by.

The resulting textured quad will have the size of the original sprite, multiplied by this value.

◆ angle

float donut::graphics::SpriteInstance::angle = 0.0f

Angle, in radians, to rotate the sprite by, around its SpriteInstance::origin.

◆ origin

vec2 donut::graphics::SpriteInstance::origin {0.0f, 0.0f}

Offset, in texture coordinates, specifying the origin relative to the bottom left of the sprite.

For example, a value of (0.5, 0.5) would represent the middle of the sprite.

◆ tintColor

Color donut::graphics::SpriteInstance::tintColor = Color::WHITE

Tint color to use in the shader.

Note
In the default shader, the output color is multiplied by this value, meaning that a value of Color::WHITE, i.e. RGBA(1, 1, 1, 1) in linear color, represents no modification to the original texture color.

The documentation for this struct was generated from the following file: