Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
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) 2025 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);
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 */
88 const SceneComponent2D& GetTransform() const;
89 ///@}
90
91protected:
93};
94
95} // namespace rendering_engine
Represents a 2D camera with position, rotation, and zoom control.
Definition camera_2d.hpp:36
SceneComponent2D & GetTransform()
Access to the underlying SceneComponent2D (transform).
Drawable2D(RenderResourceContext renderContext)
Constructs the Drawable2D with a resource context.
const glm::vec2 & GetScale() const
Gets the quad scale.
void Update(float deltaTime) override
Updates model matrix (and any other logic).
SceneComponent2D mSceneComponent
void Initialize() override
Initializes render resources.
float GetRotation() const
Gets the quad rotation angle (degrees).
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.
virtual void Draw(const Camera2D &camera)=0
Submits this quad to the renderer for drawing.
DrawableComponent(RenderResourceContext renderContext)
Constructs the DrawableComponent with a resource context.
Represents a 2D transformable scene component with position, rotation, and scale.
#define RE_API
Aggregates pointers to global rendering resource managers.