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

Persistent system that provides 2D rendering capabilities. More...

#include <GREM/graphics_2d/Renderer2D.hpp>

Public Types

using DefaultModel2DVertexShader = Model2D::VertexShader
 Default vertex shader type for drawing 2D models.
using PlainModel2DFragmentShader = Model2D::FragmentShader
 Default fragment shader type for drawing plain 2D models.
using TextModel2DFragmentShader = Model2D::FragmentShader
 Default fragment shader type for drawing text.
using TonemappingModel2DFragmentShader = Model2D::FragmentShader
 Default fragment shader type for tonemapping.

Public Member Functions

 Renderer2D (Device &device, const Renderer2DOptions &options={})
 Construct a 2D renderer.
 ~Renderer2D ()
 Destructor.
 Renderer2D (const Renderer2D &)=delete
 Copying a renderer is not allowed.
 Renderer2D (Renderer2D &&)=delete
 Moving a renderer is not allowed.
Renderer2D & operator= (const Renderer2D &)=delete
 Copying a renderer is not allowed.
Renderer2D & operator= (Renderer2D &&)=delete
 Moving a renderer is not allowed.
template<typename... ExtraBuffers>
void drawFrame (RenderPass &renderPass, StridedSpan< const Instances2DView > instanceBatches, const Camera2D &camera, const ExtraBuffers &... extraBuffers)
 Push the draw commands of a frame of 2D instance batches to a render pass.
const Texture & getInvisibleTexture2D ()
 Get the default invisible 2D texture.
const Texture & getInvisibleTexture2DArray ()
 Get the default invisible 2D array texture.
const Texture & getInvisibleTextureCube ()
 Get the default invisible cube texture.
const Texture & getInvisibleTextureCubeArray ()
 Get the default invisible cube array texture.
const Texture & getWhiteTexture2D ()
 Get the default white 2D texture.
const Texture & getWhiteTextureCube ()
 Get the default white cubemap texture.
const Texture & getFlatNormalTexture2D ()
 Get the default flat normal map 2D texture.
const Texture & getDefaultDepthTexture2D ()
 Get the default 2D depth texture.
const Texture & getDefaultDepthTexture2DArray ()
 Get the default 2D array depth texture.
const Texture & getDefaultDepthTextureCube ()
 Get the default cube depth texture.
const Texture & getDefaultDepthTextureCubeArray ()
 Get the default cube array depth texture.
const Model2D::VertexShader & getDefaultModel2DVertexShader ()
 Get the default 2D model vertex shader.
const PlainModel2DFragmentShader & getPlainModel2DFragmentShader ()
 Get the default plain 2D model fragment shader.
const Model2D::ShaderPipeline & getPlainModel2DShaderPipeline ()
 Get the default plain 2D model shader pipeline.
const TextModel2DFragmentShader & getTextModel2DFragmentShader ()
 Get the default text fragment shader.
const Model2D::ShaderPipeline & getTextModel2DShaderPipeline ()
 Get the default text shader pipeline.
const TonemappingModel2DFragmentShader & getTonemappingModel2DFragmentShader ()
 Get the default tonemapping fragment shader.
const Model2D::ShaderPipeline & getTonemappingModel2DShaderPipeline ()
 Get the default tonemapping shader pipeline.
const Model2D & getUnitSquareModel2D () const noexcept
 Get the default 2D unit square model, which holds a single mesh that forms a square using a triangle strip of 2 triangles, consisting of 4 vertices in total with the following positions (and identical texture coordinates):
const Model2D & getUnitRightAngledTriangleModel2D () const noexcept
 Get the default 2D unit right-angled triangle model, which holds a single mesh that forms a single triangle, consisting of 3 vertices in total with the following positions (and identical texture coordinates):

Detailed Description

Persistent system that provides 2D rendering capabilities.

See also
Renderer3D

Member Typedef Documentation

◆ DefaultModel2DVertexShader

Default vertex shader type for drawing 2D models.

◆ PlainModel2DFragmentShader

Default fragment shader type for drawing plain 2D models.

◆ TextModel2DFragmentShader

Default fragment shader type for drawing text.

◆ TonemappingModel2DFragmentShader

Default fragment shader type for tonemapping.

Constructor & Destructor Documentation

◆ Renderer2D() [1/3]

grem::graphics::Renderer2D::Renderer2D ( Device & device,
const Renderer2DOptions & options = {} )
explicit

Construct a 2D renderer.

Parameters
devicedevice to create the renderer for. Must outlive the renderer.
optionsinitial configuration of the renderer, see Renderer2DOptions.
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.

◆ ~Renderer2D()

grem::graphics::Renderer2D::~Renderer2D ( )

Destructor.

◆ Renderer2D() [2/3]

grem::graphics::Renderer2D::Renderer2D ( const Renderer2D & )
delete

Copying a renderer is not allowed.

◆ Renderer2D() [3/3]

grem::graphics::Renderer2D::Renderer2D ( Renderer2D && )
delete

Moving a renderer is not allowed.

Member Function Documentation

◆ operator=() [1/2]

Renderer2D & grem::graphics::Renderer2D::operator= ( const Renderer2D & )
delete

Copying a renderer is not allowed.

◆ operator=() [2/2]

Renderer2D & grem::graphics::Renderer2D::operator= ( Renderer2D && )
delete

Moving a renderer is not allowed.

◆ drawFrame()

template<typename... ExtraBuffers>
void grem::graphics::Renderer2D::drawFrame ( RenderPass & renderPass,
StridedSpan< const Instances2DView > instanceBatches,
const Camera2D & camera,
const ExtraBuffers &... extraBuffers )
inline

Push the draw commands of a frame of 2D instance batches to a render pass.

Parameters
renderPassrender pass to push the draw commands to.
instanceBatcheslist of read-only views over the instance batches to draw.
cameraperspective to render the instances from.
extraBuffersextra buffers required by the shaders used in 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.
Warning
All extra buffers required by the shaders used in the batch must be provided through the parameter pack.

◆ getInvisibleTexture2D()

const Texture & grem::graphics::Renderer2D::getInvisibleTexture2D ( )
inlinenodiscard

Get the default invisible 2D texture.

Returns
a read-only reference to the invisible 2D texture.

◆ getInvisibleTexture2DArray()

const Texture & grem::graphics::Renderer2D::getInvisibleTexture2DArray ( )
inlinenodiscard

Get the default invisible 2D array texture.

Returns
a read-only reference to the invisible 2D array texture.

◆ getInvisibleTextureCube()

const Texture & grem::graphics::Renderer2D::getInvisibleTextureCube ( )
inlinenodiscard

Get the default invisible cube texture.

Returns
a read-only reference to the invisible cube texture.

◆ getInvisibleTextureCubeArray()

const Texture & grem::graphics::Renderer2D::getInvisibleTextureCubeArray ( )
inlinenodiscard

Get the default invisible cube array texture.

Returns
a read-only reference to the invisible cube array texture.

◆ getWhiteTexture2D()

const Texture & grem::graphics::Renderer2D::getWhiteTexture2D ( )
inlinenodiscard

Get the default white 2D texture.

Returns
a read-only reference to the white 2D texture.

◆ getWhiteTextureCube()

const Texture & grem::graphics::Renderer2D::getWhiteTextureCube ( )
inlinenodiscard

Get the default white cubemap texture.

Returns
a read-only reference to the white cubemap texture.

◆ getFlatNormalTexture2D()

const Texture & grem::graphics::Renderer2D::getFlatNormalTexture2D ( )
inlinenodiscard

Get the default flat normal map 2D texture.

Returns
a read-only reference to the flat normal map 2D texture.

◆ getDefaultDepthTexture2D()

const Texture & grem::graphics::Renderer2D::getDefaultDepthTexture2D ( )
inlinenodiscard

Get the default 2D depth texture.

Returns
a read-only reference to the default 2D depth texture.

◆ getDefaultDepthTexture2DArray()

const Texture & grem::graphics::Renderer2D::getDefaultDepthTexture2DArray ( )
inlinenodiscard

Get the default 2D array depth texture.

Returns
a read-only reference to the default 2D array depth texture.

◆ getDefaultDepthTextureCube()

const Texture & grem::graphics::Renderer2D::getDefaultDepthTextureCube ( )
inlinenodiscard

Get the default cube depth texture.

Returns
a read-only reference to the default cube depth texture.

◆ getDefaultDepthTextureCubeArray()

const Texture & grem::graphics::Renderer2D::getDefaultDepthTextureCubeArray ( )
inlinenodiscard

Get the default cube array depth texture.

Returns
a read-only reference to the default cube array depth texture.

◆ getDefaultModel2DVertexShader()

const Model2D::VertexShader & grem::graphics::Renderer2D::getDefaultModel2DVertexShader ( )
nodiscard

Get the default 2D model vertex shader.

Returns
a read-only reference to the default 2D model vertex shader.

◆ getPlainModel2DFragmentShader()

const PlainModel2DFragmentShader & grem::graphics::Renderer2D::getPlainModel2DFragmentShader ( )
nodiscard

Get the default plain 2D model fragment shader.

Returns
a read-only reference to the plain 2D model fragment shader.

◆ getPlainModel2DShaderPipeline()

const Model2D::ShaderPipeline & grem::graphics::Renderer2D::getPlainModel2DShaderPipeline ( )
inlinenodiscard

Get the default plain 2D model shader pipeline.

Returns
a read-only reference to the plain 2D model shader pipeline.

◆ getTextModel2DFragmentShader()

const TextModel2DFragmentShader & grem::graphics::Renderer2D::getTextModel2DFragmentShader ( )
nodiscard

Get the default text fragment shader.

Returns
a read-only reference to the text fragment shader.

◆ getTextModel2DShaderPipeline()

const Model2D::ShaderPipeline & grem::graphics::Renderer2D::getTextModel2DShaderPipeline ( )
inlinenodiscard

Get the default text shader pipeline.

Returns
a read-only reference to the text shader pipeline.

◆ getTonemappingModel2DFragmentShader()

const TonemappingModel2DFragmentShader & grem::graphics::Renderer2D::getTonemappingModel2DFragmentShader ( )
nodiscard

Get the default tonemapping fragment shader.

Returns
a read-only reference to the tonemapping fragment shader.

◆ getTonemappingModel2DShaderPipeline()

const Model2D::ShaderPipeline & grem::graphics::Renderer2D::getTonemappingModel2DShaderPipeline ( )
inlinenodiscard

Get the default tonemapping shader pipeline.

Returns
a read-only reference to the tonemapping shader pipeline.

◆ getUnitSquareModel2D()

const Model2D & grem::graphics::Renderer2D::getUnitSquareModel2D ( ) const
inlinenodiscardnoexcept

Get the default 2D unit square model, which holds a single mesh that forms a square using a triangle strip of 2 triangles, consisting of 4 vertices in total with the following positions (and identical texture coordinates):

  • (0, 0)
  • (1, 0)
  • (0, 1)
  • (1, 1)
Returns
a read-only reference to the 2D unit square model.

◆ getUnitRightAngledTriangleModel2D()

const Model2D & grem::graphics::Renderer2D::getUnitRightAngledTriangleModel2D ( ) const
inlinenodiscardnoexcept

Get the default 2D unit right-angled triangle model, which holds a single mesh that forms a single triangle, consisting of 3 vertices in total with the following positions (and identical texture coordinates):

  • (0, 0)
  • (1, 0)
  • (0, 1)
Returns
a read-only reference to the 2D right-angled triangle model.

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