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

2D drawable component for rendering objects in 2D space. More...

#include <drawable_2d.hpp>

Inherits rendering_engine::DrawableComponent.

Inherited by rendering_engine::Quad2D.

Public Member Functions

 Drawable2D (RenderResourceContext renderContext)
 Constructs the Drawable2D with a resource context.
void Initialize () override
 Initializes render resources.
void Update (float deltaTime) override
 Updates model matrix (and any other logic).
virtual void Draw (const Camera2D &camera)=0
 Submits this quad to the renderer for drawing.
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

Protected Attributes

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

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).

Detailed Description

2D drawable component for rendering objects in 2D space.

Encapsulates a 2D transform (SceneComponent2D). Provides per-frame update, transform access, and render submission.

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

Definition at line 26 of file drawable_2d.hpp.

Constructor & Destructor Documentation

◆ Drawable2D()

rendering_engine::Drawable2D::Drawable2D ( RenderResourceContext renderContext)

Constructs the Drawable2D with a resource context.

Parameters
renderContextRendering resource context (renderer, caches).

Definition at line 6 of file drawable_2d.cpp.

7 :
8 DrawableComponent(renderContext)
9{}
DrawableComponent(RenderResourceContext renderContext)
Constructs the DrawableComponent with a resource context.

Member Function Documentation

◆ Draw()

virtual void rendering_engine::Drawable2D::Draw ( const Camera2D & camera)
pure virtual

Submits this quad to the renderer for drawing.

Implemented in rendering_engine::Quad2D.

◆ GetPosition()

const glm::vec2 & rendering_engine::Drawable2D::GetPosition ( ) const

Gets the quad position.

Definition at line 36 of file drawable_2d.cpp.

37{
38 return mSceneComponent.GetPosition();
39}
SceneComponent2D mSceneComponent

◆ GetRotation()

float rendering_engine::Drawable2D::GetRotation ( ) const

Gets the quad rotation angle (degrees).

Definition at line 41 of file drawable_2d.cpp.

42{
43 return mSceneComponent.GetRotation();
44}

◆ GetScale()

const glm::vec2 & rendering_engine::Drawable2D::GetScale ( ) const

Gets the quad scale.

Definition at line 46 of file drawable_2d.cpp.

47{
48 return mSceneComponent.GetScale();
49}

◆ GetTransform() [1/2]

SceneComponent2D & rendering_engine::Drawable2D::GetTransform ( )

Access to the underlying SceneComponent2D (transform).

Definition at line 51 of file drawable_2d.cpp.

52{
53 return mSceneComponent;
54}

◆ GetTransform() [2/2]

const SceneComponent2D & rendering_engine::Drawable2D::GetTransform ( ) const

Definition at line 56 of file drawable_2d.cpp.

57{
58 return mSceneComponent;
59}

◆ Initialize()

void rendering_engine::Drawable2D::Initialize ( )
overridevirtual

Initializes render resources.

Reimplemented from rendering_engine::DrawableComponent.

Reimplemented in rendering_engine::Quad2D.

Definition at line 11 of file drawable_2d.cpp.

12{
14}
virtual void Initialize()
Initializes render resource pointers (material, mesh, etc.). Must be called after setting material an...

◆ SetPosition()

void rendering_engine::Drawable2D::SetPosition ( const glm::vec2 & position)

Sets the quad position in 2D space.

Parameters
positionNew position vector (x, y).

Definition at line 21 of file drawable_2d.cpp.

22{
23 mSceneComponent.SetPosition(position);
24}

◆ SetRotation()

void rendering_engine::Drawable2D::SetRotation ( float angleDegrees)

Sets the quad rotation.

Parameters
angleDegreesRotation angle in degrees (counterclockwise).

Definition at line 26 of file drawable_2d.cpp.

27{
28 mSceneComponent.SetRotation(angleDegrees);
29}

◆ SetScale()

void rendering_engine::Drawable2D::SetScale ( const glm::vec2 & scale)

Sets the quad scale along each axis.

Parameters
scaleNew scale vector (x, y).

Definition at line 31 of file drawable_2d.cpp.

32{
33 mSceneComponent.SetScale(scale);
34}

◆ Update()

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

Updates model matrix (and any other logic).

Parameters
deltaTimeTime step (seconds).

Implements rendering_engine::DrawableComponent.

Reimplemented in rendering_engine::Quad2D.

Definition at line 16 of file drawable_2d.cpp.

17{
18 mSceneComponent.UpdateModelMatrix();
19}

Member Data Documentation

◆ mSceneComponent

SceneComponent2D rendering_engine::Drawable2D::mSceneComponent
protected

Definition at line 92 of file drawable_2d.hpp.


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