Rendering Engine
0.2.9
Modular Graphics Rendering Engine | v0.2.9
drawable_component.hpp
Go to the documentation of this file.
1
// This file is part of the Rendering Engine project.
2
// Author: Alexander Obzherin <alexanderobzherin@gmail.com>
3
// Copyright (c) 2026 Alexander Obzherin
4
// Distributed under the terms of the zlib License. See LICENSE.md for details.
5
6
#pragma once
7
8
#include <memory>
9
#include <string>
10
#include "
rendering_engine_export.hpp
"
11
#include "
vertex_declarations.hpp
"
12
#include "
render_resource_context.hpp
"
13
#include "
i_render_resources.hpp
"
14
#include "
material_types.hpp
"
15
16
namespace
rendering_engine
17
{
18
class
IRenderer;
19
class
Material;
20
class
ModelCache;
21
class
TextureCache;
22
class
MaterialCache;
23
class
MeshDataGpu;
24
class
Scene;
25
26
struct
RenderBatch
27
{
28
std::string
meshName
;
29
std::string
materialName
;
30
std::unique_ptr<IRenderResources>
renderResources
=
nullptr
;
31
PackedMaterialData
materialParameters
;
32
};
33
34
/**
35
* @class DrawableComponent
36
* @brief Abstract base for all drawable (renderable) objects in the engine.
37
*
38
* Provides core functionality for accessing render resources (meshes, materials, textures)
39
* and defines the initialization, update, and draw lifecycle for renderable entities.
40
*
41
* Derived classes (such as Drawable2D and Drawable3D) implement type-specific behavior for
42
* spatial transforms, camera use, and render submission.
43
*
44
* @note Not copyable or assignable.
45
* @see Drawable2D, Drawable3D
46
*/
47
class
RE_API
DrawableComponent
48
{
49
public
:
50
/**
51
* @brief Constructs the DrawableComponent with a resource context.
52
* @param renderContext Rendering resource context (renderer, caches).
53
*/
54
DrawableComponent
(
RenderResourceContext
renderContext,
Scene
& scene);
55
56
/// Virtual destructor.
57
virtual
~DrawableComponent
() =
default
;
58
59
/**
60
* @brief Initializes render resource pointers (material, mesh, etc.).
61
* Must be called after setting material and mesh names.
62
*/
63
virtual
void
Initialize();
64
65
/**
66
* @brief Updates logic (animation, movement, etc.) for this drawable.
67
* @param deltaTime Time step (seconds).
68
*/
69
virtual
void
Update
(
float
deltaTime) = 0;
70
71
/**
72
* @brief Releases all render resources owned by this drawable.
73
*
74
* Called internally by the Scene during destruction or scene shutdown.
75
* This function must free GPU and CPU-side render resources but must not
76
* remove the drawable from Scene containers.
77
*/
78
virtual
void
Shutdown();
79
80
/**
81
* @brief Requests destruction of this drawable.
82
*
83
* Schedules the drawable for deferred removal via the owning Scene.
84
* The drawable is not destroyed immediately; actual cleanup is performed
85
* at a safe point during the Scene update cycle.
86
*
87
* @note This function must be used instead of deleting the object directly.
88
*/
89
virtual
void
Destroy();
90
91
void
UpdateOnTick(
bool
in);
92
93
DrawableComponent
(
const
DrawableComponent
&) =
delete
;
94
DrawableComponent
&
operator=
(
const
DrawableComponent
&) =
delete
;
95
96
protected
:
97
void
AddRenderBatch(std::string meshName, std::string materialName);
98
99
protected
:
100
RenderResourceContext
mRenderContext
;
101
Scene
&
mScene
;
102
std::vector<RenderBatch>
mRenderBatches
;
103
104
bool
bUpdateOnTick
;
105
};
106
107
}
108
rendering_engine::DrawableComponent
Abstract base for all drawable (renderable) objects in the engine.
Definition:
drawable_component.hpp:48
rendering_engine::DrawableComponent::mRenderBatches
std::vector< RenderBatch > mRenderBatches
Definition:
drawable_component.hpp:102
rendering_engine::DrawableComponent::~DrawableComponent
virtual ~DrawableComponent()=default
Virtual destructor.
rendering_engine::DrawableComponent::mRenderContext
RenderResourceContext mRenderContext
Definition:
drawable_component.hpp:100
rendering_engine::DrawableComponent::bUpdateOnTick
bool bUpdateOnTick
Definition:
drawable_component.hpp:104
rendering_engine::DrawableComponent::operator=
DrawableComponent & operator=(const DrawableComponent &)=delete
rendering_engine::DrawableComponent::DrawableComponent
DrawableComponent(const DrawableComponent &)=delete
rendering_engine::DrawableComponent::Update
virtual void Update(float deltaTime)=0
Updates logic (animation, movement, etc.) for this drawable.
rendering_engine::DrawableComponent::mScene
Scene & mScene
Definition:
drawable_component.hpp:101
rendering_engine::Scene
Base class representing a renderable scene.
Definition:
scene.hpp:44
i_render_resources.hpp
material_types.hpp
rendering_engine
Definition:
actor.hpp:13
render_resource_context.hpp
rendering_engine_export.hpp
RE_API
#define RE_API
Definition:
rendering_engine_export.hpp:10
rendering_engine::PackedMaterialData
Contains the raw buffer data and layout metadata of packed material parameters.
Definition:
material_types.hpp:80
rendering_engine::RenderBatch
Definition:
drawable_component.hpp:27
rendering_engine::RenderBatch::renderResources
std::unique_ptr< IRenderResources > renderResources
Definition:
drawable_component.hpp:30
rendering_engine::RenderBatch::materialName
std::string materialName
Definition:
drawable_component.hpp:29
rendering_engine::RenderBatch::meshName
std::string meshName
Definition:
drawable_component.hpp:28
rendering_engine::RenderBatch::materialParameters
PackedMaterialData materialParameters
Definition:
drawable_component.hpp:31
rendering_engine::RenderResourceContext
Aggregates pointers to global rendering resource managers.
Definition:
render_resource_context.hpp:26
vertex_declarations.hpp
RenderingEngine
RenderingLibrary
Include
drawable_component.hpp
Generated by
1.9.4