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

Container for a set of 2D triangle strip meshes stored on the GPU. More...

#include <GREM/graphics_2d/Model2D.hpp>

Classes

struct  Vertex
 Data layout for the attributes of a single vertex of a 2D model mesh. More...
struct  Instance
 Data layout for the attributes of a single instance of a 2D model mesh. More...
struct  VertexShaderConstants
 Struct of default vertex shader constants. More...
struct  VertexShaderOutputs
 Struct of fields output by the default vertex shader. More...
struct  FragmentShaderConstants
 Struct of default fragment shader constants. More...
struct  FragmentShaderOutputs
 Struct of fields output by the default fragment shader. More...
struct  TextureParameters
 Struct of shader parameters representing the texture of a 2D model. More...
struct  Transformation3DParameters
 Struct of shader fields representing the 3D transformation of a 2D model. More...
struct  Node
 Node of a 2D model. More...

Public Types

using Mesh = graphics::Mesh<Vertex, NoIndex, NoParameters, Instance>
 Type of a single mesh of a 2D model.
using TextureBuffer = UniformBuffer<TextureParameters, "Model2DTexture">
 Shader buffer for 2D model texture parameters.
using Transformation3DBuffer = UniformBuffer<Transformation3DParameters, "Model2DTransformation3D">
 Shader buffer for 2D model 3D transformation parameters.
template<typename Constants, typename Outputs, typename... ExtraBuffers>
using VertexShaderBase = graphics::VertexShader<Mesh, Constants, Outputs, Camera2D::ParameterBuffer, ExtraBuffers...>
 Vertex shader for drawing 2D models.
using VertexShader = VertexShaderBase<VertexShaderConstants, VertexShaderOutputs>
 Default vertex shader for drawing 2D models.
template<typename Inputs, typename Constants, typename Outputs, typename... ExtraBuffers>
using FragmentShaderBase = graphics::FragmentShader<Mesh, Inputs, Constants, Outputs, Camera2D::ParameterBuffer, ExtraBuffers..., TextureBuffer>
 Fragment shader for drawing 2D models.
using FragmentShader = FragmentShaderBase<VertexShaderOutputs, FragmentShaderConstants, FragmentShaderOutputs>
 Default fragment shader type for drawing 2D models.
using ShaderPipeline = graphics::ShaderPipeline<Mesh>
 Shader pipeline for drawing 2D models.

Public Member Functions

 Model2D () noexcept=default
 Construct an invalid model that must be reassigned before use.
 Model2D (Device &device, Renderer2D &renderer2D, ArrayList< Node > nodes) noexcept
 Construct a model from a list of nodes.
 Model2D (Device &device, Renderer2D &renderer2D, Span< const Vertex > vertices)
 Construct a model with a single mesh from a list of vertices.
Span< const Node > getNodes () const noexcept
 Get the nodes of the model.
Box< 2, float > getBoundingBox () const noexcept
 Get the local bounding box of the model.
float getBoundingRadius () const noexcept
 Get the local bounding radius of the model.

Static Public Attributes

static constexpr VertexShaderConstants DEFAULT_VERTEX_SHADER_CONSTANTS {}
 Default 2D model vertex shader constants.
static constexpr FragmentShaderConstants DEFAULT_FRAGMENT_SHADER_CONSTANTS {}
 Default 2D model fragment shader constants.
static constexpr ShaderPipelineOptions DEFAULT_SHADER_PIPELINE_OPTIONS
 Default 2D model graphics pipeline configuration.

Detailed Description

Container for a set of 2D triangle strip meshes stored on the GPU.

Member Typedef Documentation

◆ Mesh

Type of a single mesh of a 2D model.

◆ TextureBuffer

Shader buffer for 2D model texture parameters.

◆ Transformation3DBuffer

Shader buffer for 2D model 3D transformation parameters.

◆ VertexShaderBase

template<typename Constants, typename Outputs, typename... ExtraBuffers>
using grem::graphics::Model2D::VertexShaderBase = graphics::VertexShader<Mesh, Constants, Outputs, Camera2D::ParameterBuffer, ExtraBuffers...>

Vertex shader for drawing 2D models.

Template Parameters
Constantsuser-defined aggregate type of external constants that are declared in the shader.
Outputsuser-defined aggregate type of fields that are declared in the shader and passed to the next pipeline stage.
ExtraBufferslist of buffers that the shader reads from in addition to the required 2D model buffers.

◆ VertexShader

◆ FragmentShaderBase

template<typename Inputs, typename Constants, typename Outputs, typename... ExtraBuffers>
using grem::graphics::Model2D::FragmentShaderBase = graphics::FragmentShader<Mesh, Inputs, Constants, Outputs, Camera2D::ParameterBuffer, ExtraBuffers..., TextureBuffer>

Fragment shader for drawing 2D models.

Template Parameters
Inputsuser-defined aggregate type of fields that are passed into the shader from the previous pipeline stage.
Constantsuser-defined aggregate type of external constants that are declared in the shader.
Outputsuser-defined aggregate type of fields that are declared in the shader and passed to the next pipeline stage.
ExtraBufferslist of buffers that the shader reads from in addition to the required 2D model buffers.

◆ FragmentShader

◆ ShaderPipeline

Shader pipeline for drawing 2D models.

Constructor & Destructor Documentation

◆ Model2D() [1/3]

grem::graphics::Model2D::Model2D ( )
defaultnoexcept

Construct an invalid model that must be reassigned before use.

◆ Model2D() [2/3]

grem::graphics::Model2D::Model2D ( Device & device,
Renderer2D & renderer2D,
ArrayList< Node > nodes )
inlinenoexcept

Construct a model from a list of nodes.

Parameters
devicedevice to create the model for. Must outlive the model.
renderer2Drenderer to create the model for. Must be associated with the given device. Must outlive the model.
nodesnodes that define the model. Must not be empty.

◆ Model2D() [3/3]

grem::graphics::Model2D::Model2D ( Device & device,
Renderer2D & renderer2D,
Span< const Vertex > vertices )
inline

Construct a model with a single mesh from a list of vertices.

Parameters
devicedevice to create the model for. Must outlive the model.
renderer2Drenderer to create the model for. Must be associated with the given device. Must outlive the model.
verticesvertices that define the mesh of the model.
Exceptions
graphics::Erroron failure to create the model.
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

◆ getNodes()

Span< const Node > grem::graphics::Model2D::getNodes ( ) const
inlinenodiscardnoexcept

Get the nodes of the model.

Returns
a read-only view over the nodes of the model.

◆ getBoundingBox()

Box< 2, float > grem::graphics::Model2D::getBoundingBox ( ) const
inlinenodiscardnoexcept

Get the local bounding box of the model.

Returns
the axis-aligned bounding box of the model, relative to its origin.

◆ getBoundingRadius()

float grem::graphics::Model2D::getBoundingRadius ( ) const
inlinenodiscardnoexcept

Get the local bounding radius of the model.

Returns
the maximum vertex position distance from the model origin.

Member Data Documentation

◆ DEFAULT_VERTEX_SHADER_CONSTANTS

VertexShaderConstants grem::graphics::Model2D::DEFAULT_VERTEX_SHADER_CONSTANTS {}
staticconstexpr

Default 2D model vertex shader constants.

◆ DEFAULT_FRAGMENT_SHADER_CONSTANTS

FragmentShaderConstants grem::graphics::Model2D::DEFAULT_FRAGMENT_SHADER_CONSTANTS {}
staticconstexpr

Default 2D model fragment shader constants.

◆ DEFAULT_SHADER_PIPELINE_OPTIONS

ShaderPipelineOptions grem::graphics::Model2D::DEFAULT_SHADER_PIPELINE_OPTIONS
staticconstexpr
Initial value:
{
.depthBufferMode = DepthBufferMode::NONE,
.faceCullingMode = FaceCullingMode::NONE,
}
@ TRIANGLE_STRIP
Each point, except the first two, forms a filled triangle with the previous two points.
Definition shaders.hpp:296
@ NONE
Ignore the depth buffer.
Definition shaders.hpp:59
@ NONE
Ignore facing, don't cull primitives based on their winding order.
Definition shaders.hpp:319
static const BlendState ALPHA_BLENDING_PREMULTIPLIED
Blend state to use for pre-multiplied alpha blending using the standard "over" operator.
Definition shaders.hpp:391

Default 2D model graphics pipeline configuration.


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