GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::Instances2D Class Reference

Batch of instances to be drawn in a Renderer2D frame. More...

#include <GREM/graphics_2d/Instances2D.hpp>

Public Member Functions

 Instances2D (Device &device, Renderer2D &renderer2D)
 Construct a batch of instances.
void clear ()
 Clear the batch of all instances.
void putModelInstance (const Model2D &model, const ModelInstance2D &instance)
 Add a 2D model instance to be rendered using a plain 2D model shader.
void putShadedModelInstance (const Model2D::ShaderPipeline &shaderPipeline, const Model2D &model, const ModelInstance2D &instance)
 Add a 2D model instance to be rendered using a specific shader pipeline.
void putTriangleInstance (const TriangleInstance2D &instance)
 Add a triangle instance to be rendered using a plain 2D model shader.
void putShadedTriangleInstance (const Model2D::ShaderPipeline &shaderPipeline, const TriangleInstance2D &instance)
 Add a triangle instance to be rendered using a specific shader pipeline.
void putQuadInstance (const QuadInstance2D &instance)
 Add a quad instance to be rendered using a plain 2D model shader.
void putShadedQuadInstance (const Model2D::ShaderPipeline &shaderPipeline, const QuadInstance2D &instance)
 Add a quad instance to be rendered using a specific shader pipeline.
void putRectangleInstance (const RectangleInstance2D &instance)
 Add a rectangle instance to be rendered using a plain 2D model shader.
void putShadedRectangleInstance (const Model2D::ShaderPipeline &shaderPipeline, const RectangleInstance2D &instance)
 Add a rectangle instance to be rendered using a specific shader pipeline.
void putImageInstance (const Texture &texture, const ImageInstance2D &instance={})
 Add an image instance to be rendered using a plain 2D model shader.
void putShadedImageInstance (const Model2D::ShaderPipeline &shaderPipeline, const Texture &texture, const ImageInstance2D &instance={})
 Add an image instance to be rendered using a specific shader pipeline.
void putSpriteInstance (const SpriteAtlas &spriteAtlas, SpriteID spriteID, const SpriteInstance2D &instance)
 Add a sprite instance to be rendered using a plain 2D model shader.
void putShadedSpriteInstance (const Model2D::ShaderPipeline &shaderPipeline, const SpriteAtlas &spriteAtlas, SpriteID spriteID, const SpriteInstance2D &instance)
 Add a sprite instance to be rendered using a specific shader pipeline.
void putTextInstance (const Text2D &text, const TextInstance2D &instance)
 Add a 2D text instance to be rendered using a plain 2D text shader.
void putShadedTextInstance (const Model2D::ShaderPipeline &shaderPipeline, const Text2D &text, const TextInstance2D &instance)
 Add a text instance to be rendered using a specific shader pipeline.
void putTextStringInstance (Font2D &font, UTF8StringView string, const TextStringInstance2D &instance)
 Add a 2D text string instance to be rendered using a plain 2D text shader.
void putShadedTextStringInstance (const Model2D::ShaderPipeline &shaderPipeline, Font2D &font, UTF8StringView string, const TextStringInstance2D &instance)
 Add a 2D text string instance to be rendered using a specific shader pipeline.
void putTextStringInstance (Font2D &font, StringView string, const TextStringInstance2D &instance)
 Add a 2D text string instance to be rendered using a plain 2D text shader.
void putShadedTextStringInstance (const Model2D::ShaderPipeline &shaderPipeline, Font2D &font, StringView string, const TextStringInstance2D &instance)
 Add a 2D text string instance to be rendered using a specific shader pipeline.

Detailed Description

Batch of instances to be drawn in a Renderer2D frame.

Constructor & Destructor Documentation

◆ Instances2D()

grem::graphics::Instances2D::Instances2D ( Device & device,
Renderer2D & renderer2D )
inline

Construct a batch of instances.

Parameters
devicedevice to create the batch for. Must outlive the batch.
renderer2Drenderer to create the batch for. Must be associated with the given device. Must outlive the batch.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

Member Function Documentation

◆ clear()

void grem::graphics::Instances2D::clear ( )
inline

Clear the batch of all instances.

Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ putModelInstance()

void grem::graphics::Instances2D::putModelInstance ( const Model2D & model,
const ModelInstance2D & instance )

Add a 2D model instance to be rendered using a plain 2D model shader.

Parameters
modelmodel to draw.
instanceconfiguration of the model instance to draw, see ModelInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ putShadedModelInstance()

void grem::graphics::Instances2D::putShadedModelInstance ( const Model2D::ShaderPipeline & shaderPipeline,
const Model2D & model,
const ModelInstance2D & instance )

Add a 2D model instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the model with.
modelmodel to draw.
instanceconfiguration of the model instance to draw, see ModelInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ putTriangleInstance()

void grem::graphics::Instances2D::putTriangleInstance ( const TriangleInstance2D & instance)

Add a triangle instance to be rendered using a plain 2D model shader.

Parameters
instanceconfiguration of the triangle instance to draw, see TriangleInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putQuadInstance()

◆ putShadedTriangleInstance()

void grem::graphics::Instances2D::putShadedTriangleInstance ( const Model2D::ShaderPipeline & shaderPipeline,
const TriangleInstance2D & instance )

Add a triangle instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the triangle with.
instanceconfiguration of the triangle instance to draw, see TriangleInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putShadedQuadInstance()

◆ putQuadInstance()

void grem::graphics::Instances2D::putQuadInstance ( const QuadInstance2D & instance)

Add a quad instance to be rendered using a plain 2D model shader.

Parameters
instanceconfiguration of the quad instance to draw, see QuadInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putImageInstance()
putRectangleInstance()
putSpriteInstance()

◆ putShadedQuadInstance()

void grem::graphics::Instances2D::putShadedQuadInstance ( const Model2D::ShaderPipeline & shaderPipeline,
const QuadInstance2D & instance )

Add a quad instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the quad with.
instanceconfiguration of the quad instance to draw, see QuadInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putShadedImageInstance()
putShadedRectangleInstance()
putShadedSpriteInstance()

◆ putRectangleInstance()

void grem::graphics::Instances2D::putRectangleInstance ( const RectangleInstance2D & instance)

Add a rectangle instance to be rendered using a plain 2D model shader.

Parameters
instanceconfiguration of the rectangle instance to draw, see RectangleInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putQuadInstance()
putImageInstance()
putSpriteInstance()

◆ putShadedRectangleInstance()

void grem::graphics::Instances2D::putShadedRectangleInstance ( const Model2D::ShaderPipeline & shaderPipeline,
const RectangleInstance2D & instance )

Add a rectangle instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the rectangle with.
instanceconfiguration of the rectangle instance to draw, see RectangleInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putShadedQuadInstance()
putShadedImageInstance()
putShadedSpriteInstance()

◆ putImageInstance()

void grem::graphics::Instances2D::putImageInstance ( const Texture & texture,
const ImageInstance2D & instance = {} )

Add an image instance to be rendered using a plain 2D model shader.

Parameters
texturetexture of the image to draw. Must be a valid 2D texture.
instanceconfiguration of the image instance to draw, see ImageInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putQuadInstance()
putRectangleInstance()
putSpriteInstance()

◆ putShadedImageInstance()

void grem::graphics::Instances2D::putShadedImageInstance ( const Model2D::ShaderPipeline & shaderPipeline,
const Texture & texture,
const ImageInstance2D & instance = {} )

Add an image instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the texture with.
texturetexture of the image to draw. Must be a valid 2D texture.
instanceconfiguration of the image instance to draw, see ImageInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putShadedQuadInstance()
putShadedRectangleInstance()
putShadedSpriteInstance()

◆ putSpriteInstance()

void grem::graphics::Instances2D::putSpriteInstance ( const SpriteAtlas & spriteAtlas,
SpriteID spriteID,
const SpriteInstance2D & instance )

Add a sprite instance to be rendered using a plain 2D model shader.

Parameters
spriteAtlassprite atlas to fetch the sprite image from.
spriteIDidentifier of the sprite in the atlas to draw. Must be a valid sprite identifier obtained from the given atlas.
instanceconfiguration of the sprite instance to draw, see SpriteInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putQuadInstance()
putImageInstance()
putRectangleInstance()

◆ putShadedSpriteInstance()

void grem::graphics::Instances2D::putShadedSpriteInstance ( const Model2D::ShaderPipeline & shaderPipeline,
const SpriteAtlas & spriteAtlas,
SpriteID spriteID,
const SpriteInstance2D & instance )

Add a sprite instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the sprite with.
spriteAtlassprite atlas to fetch the sprite image from.
spriteIDidentifier of the sprite in the atlas to draw. Must be a valid sprite identifier obtained from the given atlas.
instanceconfiguration of the sprite instance to draw, see SpriteInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putShadedQuadInstance()
putShadedImageInstance()
putShadedRectangleInstance()

◆ putTextInstance()

void grem::graphics::Instances2D::putTextInstance ( const Text2D & text,
const TextInstance2D & instance )

Add a 2D text instance to be rendered using a plain 2D text shader.

Parameters
textshaped text to draw.
instanceconfiguration of the text instance to draw, see TextInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putTextStringInstance()

◆ putShadedTextInstance()

void grem::graphics::Instances2D::putShadedTextInstance ( const Model2D::ShaderPipeline & shaderPipeline,
const Text2D & text,
const TextInstance2D & instance )

Add a text instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the text with.
textshaped text to draw.
instanceconfiguration of the text instance to draw, see TextInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
See also
putShadedTextStringInstance()

◆ putTextStringInstance() [1/2]

void grem::graphics::Instances2D::putTextStringInstance ( Font2D & font,
UTF8StringView string,
const TextStringInstance2D & instance )

Add a 2D text string instance to be rendered using a plain 2D text shader.

Parameters
fontfont from which to shape the text.
stringUTF-8-encoded string to shape the text from.
instanceconfiguration of the text string instance to draw, see TextStringInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
Right-to-left text shaping is currently not supported.
Grapheme clusters are currently not supported, and may be rendered incorrectly. Only one Unicode code point is rendered at a time.
Warning
If the string contains invalid UTF-8, the invalid code points will generate unspecified glyphs that may have any appearance.
See also
putTextInstance()

◆ putShadedTextStringInstance() [1/2]

void grem::graphics::Instances2D::putShadedTextStringInstance ( const Model2D::ShaderPipeline & shaderPipeline,
Font2D & font,
UTF8StringView string,
const TextStringInstance2D & instance )

Add a 2D text string instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the text with.
fontfont from which to shape the text.
stringUTF-8-encoded string to shape the text from.
instanceconfiguration of the text string instance to draw, see TextStringInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
Right-to-left text shaping is currently not supported.
Grapheme clusters are currently not supported, and may be rendered incorrectly. Only one Unicode code point is rendered at a time.
Warning
If the string contains invalid UTF-8, the invalid code points will generate unspecified glyphs that may have any appearance.
See also
putShadedTextInstance()

◆ putTextStringInstance() [2/2]

void grem::graphics::Instances2D::putTextStringInstance ( Font2D & font,
StringView string,
const TextStringInstance2D & instance )

Add a 2D text string instance to be rendered using a plain 2D text shader.

Parameters
fontfont from which to shape the text.
stringstring to shape the text from, which will be interpreted as being UTF-8-encoded.
instanceconfiguration of the text string instance to draw, see TextStringInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
Right-to-left text shaping is currently not supported.
Grapheme clusters are currently not supported, and may be rendered incorrectly. Only one Unicode code point is rendered at a time.
Warning
If the string contains invalid UTF-8, the invalid code points will generate unspecified glyphs that may have any appearance.
See also
putTextInstance()

◆ putShadedTextStringInstance() [2/2]

void grem::graphics::Instances2D::putShadedTextStringInstance ( const Model2D::ShaderPipeline & shaderPipeline,
Font2D & font,
StringView string,
const TextStringInstance2D & instance )

Add a 2D text string instance to be rendered using a specific shader pipeline.

Parameters
shaderPipelineshader pipeline to render the text with.
fontfont from which to shape the text.
stringstring to shape the text from, which will be interpreted as being UTF-8-encoded.
instanceconfiguration of the text string instance to draw, see TextStringInstance2D.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
Right-to-left text shaping is currently not supported.
Grapheme clusters are currently not supported, and may be rendered incorrectly. Only one Unicode code point is rendered at a time.
Warning
If the string contains invalid UTF-8, the invalid code points will generate unspecified glyphs that may have any appearance.
See also
putShadedTextInstance()

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