Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
rendering_engine::Quad2D Class Reference

2D drawable component for rendering rectangular primitives. More...

#include <quad_2d.hpp>

Inherits rendering_engine::Drawable2D.

Public Member Functions

 Quad2D (RenderResourceContext renderContext)
 Constructs the Quad2D with a render context.
void Initialize () override
 Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names.
void Update (float deltaTime) override
 Updates logic (animation, movement, etc.) for this drawable.
void Draw (const Camera2D &camera) override
 Submits this quad to the renderer for drawing.
 Quad2D (const Quad2D &rhs)=delete
 <
Quad2Doperator= (const Quad2D &rhs)=delete
void SetMaterialName (const std::string &materialName)
 Sets the material to use (by name).
void SetMeshName (const std::string &meshName)
 <
Public Member Functions inherited from rendering_engine::Drawable2D
 Drawable2D (RenderResourceContext renderContext)
 Constructs the Drawable2D with a resource context.
void SetPosition (const glm::vec2 &position)
 Sets the quad position in 2D space.
void SetRotation (float angleDegrees)
 Sets the quad rotation.
void SetScale (const glm::vec2 &scale)
 Sets the quad scale along each axis.
const glm::vec2 & GetPosition () const
 Gets the quad position.
float GetRotation () const
 Gets the quad rotation angle (degrees).
const glm::vec2 & GetScale () const
 Gets the quad scale.
SceneComponent2DGetTransform ()
 Access to the underlying SceneComponent2D (transform).
const SceneComponent2DGetTransform () const
Public Member Functions inherited from rendering_engine::DrawableComponent
 DrawableComponent (RenderResourceContext renderContext)
 Constructs the DrawableComponent with a resource context.
virtual ~DrawableComponent ()=default
 Virtual destructor.
virtual void Shutdown ()
 DrawableComponent (const DrawableComponent &)=delete
DrawableComponentoperator= (const DrawableComponent &)=delete

Additional Inherited Members

Protected Member Functions inherited from rendering_engine::DrawableComponent
void SetMaterialName (const std::string &materialName)
 Sets the material to use (by name).
void SetMeshName (const std::string &meshName)
 Sets the mesh to use (by name).
Protected Attributes inherited from rendering_engine::Drawable2D
SceneComponent2D mSceneComponent
Protected Attributes inherited from rendering_engine::DrawableComponent
RenderResourceContext mRenderContext
std::unique_ptr< IRenderResourcesmRenderResources
std::string mMaterialName
std::string mMeshName
MaterialmMaterial
PackedMaterialData mMaterialParameters
MeshDataGpumMeshData

Detailed Description

2D drawable component for rendering rectangular primitives.

Represents a simple 2D quad used for sprites, UI widgets, text, or procedural materials. Provides a lightweight implementation of a 2D drawable with transform and material properties inherited from Drawable2D.

Note
Not copyable or assignable.
See also
Drawable2D, DrawableComponent, SceneComponent2D, Camera2D

Definition at line 24 of file quad_2d.hpp.

Constructor & Destructor Documentation

◆ Quad2D() [1/2]

rendering_engine::Quad2D::Quad2D ( RenderResourceContext renderContext)

Constructs the Quad2D with a render context.

Parameters
renderContextResource context.

Definition at line 9 of file quad_2d.cpp.

10 :
11 Drawable2D(renderContext)
12{}
Drawable2D(RenderResourceContext renderContext)
Constructs the Drawable2D with a resource context.

◆ Quad2D() [2/2]

rendering_engine::Quad2D::Quad2D ( const Quad2D & rhs)
delete

<

Sets the mesh to use (by name).

Parameters
meshNameName of the mesh.

Member Function Documentation

◆ Draw()

void rendering_engine::Quad2D::Draw ( const Camera2D & camera)
overridevirtual

Submits this quad to the renderer for drawing.

Implements rendering_engine::Drawable2D.

Definition at line 24 of file quad_2d.cpp.

25{
26 Transformations2D transformations;
27 transformations.model = GetTransform().GetModelMatrix();
28 transformations.view = camera.GetWorldView();
29 transformations.proj = camera.GetProjectionMatrix();
30
31 mRenderResources->SubmitResources(transformations, mMaterialParameters);
32}
SceneComponent2D & GetTransform()
Access to the underlying SceneComponent2D (transform).
std::unique_ptr< IRenderResources > mRenderResources
const glm::mat4 & GetModelMatrix() const
Gets the model matrix for this component.

◆ Initialize()

void rendering_engine::Quad2D::Initialize ( )
overridevirtual

Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names.

Reimplemented from rendering_engine::Drawable2D.

Definition at line 14 of file quad_2d.cpp.

15{
17}
void Initialize() override
Initializes render resources.

◆ operator=()

Quad2D & rendering_engine::Quad2D::operator= ( const Quad2D & rhs)
delete

◆ SetMaterialName()

void rendering_engine::DrawableComponent::SetMaterialName ( const std::string & materialName)

Sets the material to use (by name).

Parameters
materialNameName of the material.

Definition at line 72 of file drawable_component.cpp.

40{
41 mMaterialName = materialName;
42}

◆ SetMeshName()

void rendering_engine::DrawableComponent::SetMeshName ( const std::string & meshName)

<

Sets the material to use (by name).

Parameters
materialNameName of the material.

Definition at line 78 of file drawable_component.cpp.

44{
45 mMeshName = meshName;
46}

◆ Update()

void rendering_engine::Quad2D::Update ( float deltaTime)
overridevirtual

Updates logic (animation, movement, etc.) for this drawable.

Parameters
deltaTimeTime step (seconds).

Reimplemented from rendering_engine::Drawable2D.

Definition at line 19 of file quad_2d.cpp.

20{
21 Drawable2D::Update(deltaTime);
22}
void Update(float deltaTime) override
Updates model matrix (and any other logic).

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