Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
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) 2025 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>
14#include "material_types.hpp"
15
16namespace rendering_engine
17{
18class IRenderer;
19class Material;
20class ModelCache;
21class TextureCache;
22class MaterialCache;
23class MeshDataGpu;
24
25/**
26 * @class DrawableComponent
27 * @brief Abstract base for all drawable (renderable) objects in the engine.
28 *
29 * Provides core functionality for accessing render resources (meshes, materials, textures)
30 * and defines the initialization, update, and draw lifecycle for renderable entities.
31 *
32 * Derived classes (such as Drawable2D and Drawable3D) implement type-specific behavior for
33 * spatial transforms, camera use, and render submission.
34 *
35 * @note Not copyable or assignable.
36 * @see Drawable2D, Drawable3D
37 */
39{
40public:
41 /**
42 * @brief Constructs the DrawableComponent with a resource context.
43 * @param renderContext Rendering resource context (renderer, caches).
44 */
46
47 /// Virtual destructor.
48 virtual ~DrawableComponent() = default;
49
50 /**
51 * @brief Initializes render resource pointers (material, mesh, etc.).
52 * Must be called after setting material and mesh names.
53 */
54 virtual void Initialize();
55
56 /**
57 * @brief Updates logic (animation, movement, etc.) for this drawable.
58 * @param deltaTime Time step (seconds).
59 */
60 virtual void Update(float deltaTime) = 0;
61
62 virtual void Shutdown();
63
66
67protected:
68 /**
69 * @brief Sets the material to use (by name).
70 * @param materialName Name of the material.
71 */
72 void SetMaterialName(const std::string& materialName);
73
74 /**
75 * @brief Sets the mesh to use (by name).
76 * @param meshName Name of the mesh.
77 */
78 void SetMeshName(const std::string& meshName);
79
80protected:
82 std::unique_ptr<IRenderResources> mRenderResources;
83
84 std::string mMaterialName;
85 std::string mMeshName;
86
90};
91
92}
93
virtual ~DrawableComponent()=default
Virtual destructor.
void SetMaterialName(const std::string &materialName)
Sets the material to use (by name).
DrawableComponent & operator=(const DrawableComponent &)=delete
DrawableComponent(const DrawableComponent &)=delete
std::unique_ptr< IRenderResources > mRenderResources
virtual void Initialize()
Initializes render resource pointers (material, mesh, etc.). Must be called after setting material an...
virtual void Update(float deltaTime)=0
Updates logic (animation, movement, etc.) for this drawable.
void SetMeshName(const std::string &meshName)
Sets the mesh to use (by name).
DrawableComponent(RenderResourceContext renderContext)
Constructs the DrawableComponent with a resource context.
Defines an abstract interface for rendering backends.
Manages creation, storage, and lifecycle of Material objects within the rendering engine.
Represents a material instance with parameter values, texture bindings, and rendering configuration.
Definition material.hpp:30
Manages mesh data in RAM and GPU, including upload and release operations.
Manages loading, caching, and GPU residency of all model/mesh resources.
Manages texture loading, GPU uploading, and caching for reuse.
#define RE_API
Contains the raw buffer data and layout metadata of packed material parameters.
Aggregates pointers to global rendering resource managers.