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

Configuration of a 2D textured quad instance, 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 texture. More...
 
const Texturetexture
 Non-owning pointer to the texture to be drawn. More...
 
vec2 position {0.0f, 0.0f}
 Position, in world coordinates, to render the texture at, with respect to its TextureInstance::origin. More...
 
vec2 scale {1.0f, 1.0f}
 Coefficients to scale the size of the texture by. More...
 
float angle = 0.0f
 Angle, in radians, to rotate the texture by, around its TextureInstance::origin. More...
 
vec2 origin {0.0f, 0.0f}
 Offset, in texture coordinates, specifying the origin relative to the bottom left of the texture. 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 textured quad instance, for drawing as part of a RenderPass.

Required fields:

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

Member Data Documentation

◆ shader

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

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

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

◆ texture

const Texture* donut::graphics::TextureInstance::texture

Non-owning pointer to the texture to be drawn.

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::TextureInstance::position {0.0f, 0.0f}

Position, in world coordinates, to render the texture at, with respect to its TextureInstance::origin.

◆ scale

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

Coefficients to scale the size of the texture by.

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

◆ angle

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

Angle, in radians, to rotate the texture by, around its TextureInstance::origin.

◆ origin

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

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

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

◆ textureOffset

vec2 donut::graphics::TextureInstance::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 TextureInstance::textureScale.

◆ textureScale

vec2 donut::graphics::TextureInstance::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 TextureInstance::textureOffset.

◆ tintColor

Color donut::graphics::TextureInstance::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: