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

Abstract base for all drawable (renderable) objects in the engine. More...

#include <drawable_component.hpp>

Inherited by rendering_engine::Drawable2D, and rendering_engine::Drawable3D.

Public Member Functions

 DrawableComponent (RenderResourceContext renderContext)
 Constructs the DrawableComponent with a resource context.
virtual ~DrawableComponent ()=default
 Virtual destructor.
virtual void Initialize ()
 Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names.
virtual void Update (float deltaTime)=0
 Updates logic (animation, movement, etc.) for this drawable.
virtual void Shutdown ()
 DrawableComponent (const DrawableComponent &)=delete
DrawableComponentoperator= (const DrawableComponent &)=delete

Protected Member Functions

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

RenderResourceContext mRenderContext
std::unique_ptr< IRenderResourcesmRenderResources
std::string mMaterialName
std::string mMeshName
MaterialmMaterial
PackedMaterialData mMaterialParameters
MeshDataGpumMeshData

Detailed Description

Abstract base for all drawable (renderable) objects in the engine.

Provides core functionality for accessing render resources (meshes, materials, textures) and defines the initialization, update, and draw lifecycle for renderable entities.

Derived classes (such as Drawable2D and Drawable3D) implement type-specific behavior for spatial transforms, camera use, and render submission.

Note
Not copyable or assignable.
See also
Drawable2D, Drawable3D

Definition at line 38 of file drawable_component.hpp.

Constructor & Destructor Documentation

◆ DrawableComponent() [1/2]

rendering_engine::DrawableComponent::DrawableComponent ( RenderResourceContext renderContext)

Constructs the DrawableComponent with a resource context.

Parameters
renderContextRendering resource context (renderer, caches).

Definition at line 13 of file drawable_component.cpp.

14 :
15 mRenderContext(renderContext),
16 mMaterial(nullptr),
17 mMeshData(nullptr)
18{
19 mRenderResources = std::unique_ptr<IRenderResources>(mRenderContext.renderer->ProvideRenderResources());
20}
std::unique_ptr< IRenderResources > mRenderResources

◆ ~DrawableComponent()

virtual rendering_engine::DrawableComponent::~DrawableComponent ( )
virtualdefault

Virtual destructor.

◆ DrawableComponent() [2/2]

rendering_engine::DrawableComponent::DrawableComponent ( const DrawableComponent & )
delete

Member Function Documentation

◆ Initialize()

void rendering_engine::DrawableComponent::Initialize ( )
virtual

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

Reimplemented in rendering_engine::Drawable2D, rendering_engine::Drawable3D, rendering_engine::Quad2D, and rendering_engine::StaticMesh.

Definition at line 22 of file drawable_component.cpp.

23{
24 mMaterial = mRenderContext.materialCache->GetMaterial(mMaterialName);
25 mMaterialParameters = mMaterial->PackMaterialParameters();
26 mMeshData = mRenderContext.meshCache->GetMeshResources(mMeshName).get();
27
28 mRenderResources->Initialize(mMaterial, mMeshData, mRenderContext.textureCache);
29}

◆ operator=()

DrawableComponent & rendering_engine::DrawableComponent::operator= ( const DrawableComponent & )
delete

◆ SetMaterialName()

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

Sets the material to use (by name).

Parameters
materialNameName of the material.

Definition at line 39 of file drawable_component.cpp.

40{
41 mMaterialName = materialName;
42}

◆ SetMeshName()

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

Sets the mesh to use (by name).

Parameters
meshNameName of the mesh.

Definition at line 43 of file drawable_component.cpp.

44{
45 mMeshName = meshName;
46}

◆ Shutdown()

void rendering_engine::DrawableComponent::Shutdown ( )
virtual

Definition at line 31 of file drawable_component.cpp.

32{
34 {
35 mRenderResources->Shutdown();
36 }
37}

◆ Update()

virtual void rendering_engine::DrawableComponent::Update ( float deltaTime)
pure virtual

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

Parameters
deltaTimeTime step (seconds).

Implemented in rendering_engine::Drawable2D, rendering_engine::Drawable3D, rendering_engine::Quad2D, and rendering_engine::StaticMesh.

Member Data Documentation

◆ mMaterial

Material* rendering_engine::DrawableComponent::mMaterial
protected

Definition at line 87 of file drawable_component.hpp.

◆ mMaterialName

std::string rendering_engine::DrawableComponent::mMaterialName
protected

Definition at line 84 of file drawable_component.hpp.

◆ mMaterialParameters

PackedMaterialData rendering_engine::DrawableComponent::mMaterialParameters
protected

Definition at line 88 of file drawable_component.hpp.

◆ mMeshData

MeshDataGpu* rendering_engine::DrawableComponent::mMeshData
protected

Definition at line 89 of file drawable_component.hpp.

◆ mMeshName

std::string rendering_engine::DrawableComponent::mMeshName
protected

Definition at line 85 of file drawable_component.hpp.

◆ mRenderContext

RenderResourceContext rendering_engine::DrawableComponent::mRenderContext
protected

Definition at line 81 of file drawable_component.hpp.

◆ mRenderResources

std::unique_ptr<IRenderResources> rendering_engine::DrawableComponent::mRenderResources
protected

Definition at line 82 of file drawable_component.hpp.


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