Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
quad_2d.cpp
Go to the documentation of this file.
1#include "quad_2d.hpp"
2#include "camera_2d.hpp"
5#include "scene.hpp"
6
7namespace rendering_engine
8{
9
11 :
12 Drawable2D(renderContext, scene)
13{}
14
16{
18}
19
20void Quad2D::Update(float deltaTime)
21{
22 Drawable2D::Update(deltaTime);
23}
24
25void Quad2D::Draw(const Camera2D& camera)
26{
27 Transformations2D transformations;
28 transformations.model = GetTransform().GetWorldMatrix();
29 transformations.view = camera.GetWorldView();
30 transformations.proj = camera.GetProjectionMatrix();
31
32 for (auto& renderBatch : mRenderBatches)
33 {
34 renderBatch.renderResources->SubmitResources(transformations, renderBatch.materialParameters);
35 }
36}
37
38} // namespace rendering_engine
Represents a 2D camera with position, rotation, and zoom control.
Definition: camera_2d.hpp:36
glm::mat4 GetProjectionMatrix() const
Returns the current orthographic projection matrix.
Definition: camera_2d.cpp:30
const glm::mat4 & GetWorldView() const
Gets the world-view (model) matrix for the camera.
Definition: camera_2d.cpp:87
2D drawable component for rendering objects in 2D space.
Definition: drawable_2d.hpp:27
SceneComponent2D & GetTransform()
Access to the underlying SceneComponent2D (transform).
Definition: drawable_2d.cpp:55
void Update(float deltaTime) override
Updates model matrix (and any other logic).
Definition: drawable_2d.cpp:17
void Initialize() override
Initializes render resources.
Definition: drawable_2d.cpp:12
std::vector< RenderBatch > mRenderBatches
Quad2D(RenderResourceContext renderContext, Scene &scene)
Constructs the Quad2D with a render context.
Definition: quad_2d.cpp:10
void Initialize() override
Initializes render resource pointers (material, mesh, etc.). Must be called after setting material an...
Definition: quad_2d.cpp:15
void Update(float deltaTime) override
Updates logic (animation, movement, etc.) for this drawable.
Definition: quad_2d.cpp:20
void Draw(const Camera2D &camera) override
Submits this quad to the renderer for drawing.
Definition: quad_2d.cpp:25
const glm::mat4 & GetWorldMatrix()
Returns the world transformation matrix.
Base class representing a renderable scene.
Definition: scene.hpp:44
Aggregates pointers to global rendering resource managers.
Contains transformation matrices for 2D rendering.
glm::mat4 view
View (camera) transformation matrix.
glm::mat4 proj
Projection transformation matrix.
glm::mat4 model
Model transformation matrix.