Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
drawable_2d.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
11
12namespace rendering_engine
13{
15
16/**
17 * @class Drawable2D
18 * @brief 2D drawable component for rendering objects in 2D space.
19 *
20 * Encapsulates a 2D transform (SceneComponent2D).
21 * Provides per-frame update, transform access, and render submission.
22 *
23 * @note Not copyable or assignable.
24 * @see DrawableComponent, SceneComponent2D, Camera2D
25 */
27{
28public:
29 /**
30 * @brief Constructs the Drawable2D with a resource context.
31 * @param renderContext Rendering resource context (renderer, caches).
32 */
33 Drawable2D(RenderResourceContext renderContext, Scene& scene);
34
35 /**
36 * @brief Initializes render resources.
37 */
38 void Initialize() override;
39
40 /**
41 * @brief Updates model matrix (and any other logic).
42 * @param deltaTime Time step (seconds).
43 */
44 void Update(float deltaTime) override;
45
46 /**
47 * @brief Submits this quad to the renderer for drawing.
48 */
49 virtual void Draw(const Camera2D& camera) = 0;
50
51 /**
52 * @brief Sets the quad position in 2D space.
53 * @param position New position vector (x, y).
54 */
55 void SetPosition(const glm::vec2& position);
56
57 /**
58 * @brief Sets the quad rotation.
59 * @param angleDegrees Rotation angle in degrees (counterclockwise).
60 */
61 void SetRotation(float angleDegrees);
62
63 /**
64 * @brief Sets the quad scale along each axis.
65 * @param scale New scale vector (x, y).
66 */
67 void SetScale(const glm::vec2& scale);
68
69 /**
70 * @brief Gets the quad position.
71 */
72 const glm::vec2& GetPosition() const;
73
74 /**
75 * @brief Gets the quad rotation angle (degrees).
76 */
77 float GetRotation() const;
78
79 /**
80 * @brief Gets the quad scale.
81 */
82 const glm::vec2& GetScale() const;
83
84 /**
85 * @brief Access to the underlying SceneComponent2D (transform).
86 */
87 SceneComponent2D& GetTransform();
88 const SceneComponent2D& GetTransform() const;
89 ///@}
90
91 /**
92 * @copydoc DrawableComponent::Destroy
93 */
94 void Destroy() override;
95
96protected:
98};
99
100} // namespace rendering_engine
Represents a 2D camera with position, rotation, and zoom control.
Definition: camera_2d.hpp:36
2D drawable component for rendering objects in 2D space.
Definition: drawable_2d.hpp:27
SceneComponent2D mSceneComponent
Definition: drawable_2d.hpp:97
virtual void Draw(const Camera2D &camera)=0
Submits this quad to the renderer for drawing.
Abstract base for all drawable (renderable) objects in the engine.
Represents a hierarchical 2D transform component.
Base class representing a renderable scene.
Definition: scene.hpp:44
#define RE_API
Aggregates pointers to global rendering resource managers.