Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
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, rendering_engine::Rectangle2D, rendering_engine::Sprite2D, and rendering_engine::TextBlock2D.

Public Member Functions

 Drawable2D (RenderResourceContext renderContext, Scene &scene)
 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
 
void Destroy () override
 Requests destruction of this drawable.
 
- Public Member Functions inherited from rendering_engine::DrawableComponent
 DrawableComponent (RenderResourceContext renderContext, Scene &scene)
 Constructs the DrawableComponent with a resource context.
 
virtual ~DrawableComponent ()=default
 Virtual destructor.
 
virtual void Shutdown ()
 Releases all render resources owned by this drawable.
 
void UpdateOnTick (bool in)
 
 DrawableComponent (const DrawableComponent &)=delete
 
DrawableComponentoperator= (const DrawableComponent &)=delete
 

Protected Attributes

SceneComponent2D mSceneComponent
 
- Protected Attributes inherited from rendering_engine::DrawableComponent
RenderResourceContext mRenderContext
 
ScenemScene
 
std::vector< RenderBatchmRenderBatches
 
bool bUpdateOnTick
 

Additional Inherited Members

- Protected Member Functions inherited from rendering_engine::DrawableComponent
void AddRenderBatch (std::string meshName, std::string materialName)
 

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,
Scene scene 
)

Constructs the Drawable2D with a resource context.

Parameters
renderContextRendering resource context (renderer, caches).

Definition at line 7 of file drawable_2d.cpp.

8 :
9 DrawableComponent(renderContext, scene)
10{}
DrawableComponent(RenderResourceContext renderContext, Scene &scene)
Constructs the DrawableComponent with a resource context.

Member Function Documentation

◆ Destroy()

void rendering_engine::Drawable2D::Destroy ( )
overridevirtual

Requests destruction of this drawable.

Schedules the drawable for deferred removal via the owning Scene. The drawable is not destroyed immediately; actual cleanup is performed at a safe point during the Scene update cycle.

Note
This function must be used instead of deleting the object directly.

Reimplemented from rendering_engine::DrawableComponent.

Definition at line 65 of file drawable_2d.cpp.

66{
68}
void DestroyDrawable2D(Drawable2D *drawable2D)
Schedules a 2D drawable for deferred destruction.
Definition scene.cpp:154

◆ 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, rendering_engine::Rectangle2D, rendering_engine::Sprite2D, and rendering_engine::TextBlock2D.

◆ GetPosition()

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

Gets the quad position.

Definition at line 40 of file drawable_2d.cpp.

41{
43}
SceneComponent2D mSceneComponent
const glm::vec2 & GetPosition() const
Gets the current position.

◆ GetRotation()

float rendering_engine::Drawable2D::GetRotation ( ) const

Gets the quad rotation angle (degrees).

Definition at line 45 of file drawable_2d.cpp.

46{
48}
float GetRotation() const
Gets the current rotation angle (in degrees).

◆ GetScale()

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

Gets the quad scale.

Definition at line 50 of file drawable_2d.cpp.

51{
53}
const glm::vec2 & GetScale() const
Gets the current scale.

◆ GetTransform() [1/2]

SceneComponent2D & rendering_engine::Drawable2D::GetTransform ( )

Access to the underlying SceneComponent2D (transform).

Definition at line 55 of file drawable_2d.cpp.

56{
57 return mSceneComponent;
58}

◆ GetTransform() [2/2]

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

Definition at line 60 of file drawable_2d.cpp.

61{
62 return mSceneComponent;
63}

◆ Initialize()

void rendering_engine::Drawable2D::Initialize ( )
overridevirtual

Initializes render resources.

Reimplemented from rendering_engine::DrawableComponent.

Reimplemented in rendering_engine::Quad2D, rendering_engine::Rectangle2D, rendering_engine::Sprite2D, and rendering_engine::TextBlock2D.

Definition at line 12 of file drawable_2d.cpp.

13{
15}
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 25 of file drawable_2d.cpp.

26{
28}
void SetPosition(const glm::vec2 &position)
Sets the local position of this component.

◆ SetRotation()

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

Sets the quad rotation.

Parameters
angleDegreesRotation angle in degrees (counterclockwise).

Definition at line 30 of file drawable_2d.cpp.

31{
32 mSceneComponent.SetRotation(angleDegrees);
33}
void SetRotation(float angleDegrees)
Sets the rotation angle in degrees.

◆ 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 35 of file drawable_2d.cpp.

36{
38}
void SetScale(const glm::vec2 &scale)
Sets the scale in each dimension.

◆ 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, rendering_engine::Rectangle2D, rendering_engine::Sprite2D, and rendering_engine::TextBlock2D.

Definition at line 17 of file drawable_2d.cpp.

18{
19 if (bUpdateOnTick)
20 {
22 }
23}
void UpdateWorldMatrix()
Recomputes the world transformation matrix.

Member Data Documentation

◆ mSceneComponent

SceneComponent2D rendering_engine::Drawable2D::mSceneComponent
protected

Definition at line 97 of file drawable_2d.hpp.


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