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

Configuration of a 2D rectangle instance, optionally textured, 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 rectangle. More...
 
const Texturetexture = Texture::WHITE
 Non-owning pointer to a texture to apply to the rectangle. More...
 
vec2 position {0.0f, 0.0f}
 Position, in world coordinates, to render the rectangle at, with respect to its RectangleInstance::origin. More...
 
vec2 size {1.0f, 1.0f}
 Size of the rectangle, in world coordinates. More...
 
float angle = 0.0f
 Angle, in radians, to rotate the rectangle by, around its RectangleInstance::origin. More...
 
vec2 origin {0.0f, 0.0f}
 Offset, in texture coordinates, specifying the origin relative to the bottom left of the rectangle. More...
 
vec2 textureOffset {0.0f, 0.0f}
 Offset, in texture coordinates, to apply to the texture coordinates before sampling the texture. More...
 
vec2 textureScale {1.0f, 1.0f}
 Coefficients to scale the texture coordinates by before sampling the texture. More...
 
Color tintColor = Color::WHITE
 Tint color to use in the shader. More...
 

Detailed Description

Configuration of a 2D rectangle instance, optionally textured, for drawing as part of a RenderPass.

Note
Consecutive 2D instances with the same shader and texture will be batched and rendered together.
See also
QuadInstance
TextureInstance
SpriteInstance
Examples
example_game.cpp, and example_rectangle.cpp.

Member Data Documentation

◆ shader

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

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

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

◆ texture

const Texture* donut::graphics::RectangleInstance::texture = Texture::WHITE

Non-owning pointer to a texture to apply to the rectangle.

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

◆ position

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

Position, in world coordinates, to render the rectangle at, with respect to its RectangleInstance::origin.

Examples
example_game.cpp, and example_rectangle.cpp.

◆ size

vec2 donut::graphics::RectangleInstance::size {1.0f, 1.0f}

Size of the rectangle, in world coordinates.

◆ angle

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

Angle, in radians, to rotate the rectangle by, around its RectangleInstance::origin.

◆ origin

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

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

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

◆ textureOffset

vec2 donut::graphics::RectangleInstance::textureOffset {0.0f, 0.0f}

Offset, in texture coordinates, to apply to the texture coordinates before sampling the texture.

Note
This unscaled offset is applied after scaling the texture coordinates by the RectangleInstance::textureScale.

◆ textureScale

vec2 donut::graphics::RectangleInstance::textureScale {1.0f, 1.0f}

Coefficients to scale the texture coordinates by before sampling the texture.

Note
The texture coordinates are scaled before applying the unscaled RectangleInstance::textureOffset.

◆ tintColor

Color donut::graphics::RectangleInstance::tintColor = Color::WHITE

Tint color to use in the shader.

When no texture is specified, this controls the base color of the rectangle.

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: