Vivid
Loading...
Searching...
No Matches
Renderer2D.h
1#pragma once
2
3#include "common/types/SmartPointers.h"
4#include "utils/Error.h"
5#include "Renderer.h"
6#include "core/ecs/components/model/Mesh.h"
7#include "editor/camera/movable/EditorCamera.h"
8#include "common/maths/Vec.h"
9
10namespace Vivid
11{
17 struct Storage
18 {
19 Ref<VertexArray> vao;
20 Ref<Shader> quadShader;
21 Ref<Shader> lineShader;
22 Ref<Shader> ellipseShader;
23 Vector<Vertex> quadVertices;
24 Vector<unsigned int> quadIndices;
25 Vector<Vertex> ellipseVertices;
26 Vector<unsigned int> ellipseIndices;
27 Vector<Vertex> lineVertices;
28 Vector<unsigned int> lineIndices;
29 };
30
39 {
40 private:
41 static Storage s_Storage;
42
43 Renderer2D() = default;
44 ~Renderer2D() = default;
45
46 static void drawQuad(Maths::Vec2 vertex1, Maths::Vec2 vertex2, Maths::Vec2 vertex3, Maths::Vec2 vertex4, Maths::Vec3 color);
47 static void drawQuad(float x, float y, float width, float height, const Maths::Vec3& color);
48 static void drawEllipse(Maths::Vec2 center, float radiusX, float radiusY, Maths::Vec3 color);
49 static void drawLine(Maths::Vec2 vertex1, Maths::Vec2 vertex2, Maths::Vec2 vertex3, Maths::Vec2 vertex4, Maths::Vec3 color);
50
51 public:
57 static void Init(int reserveVertices = 10000);
62 static void BeginScene();
67 static void EndScene();
68
69
79 static void DrawQuad(float x, float y, float width, float height, const Maths::Vec3& color);
80
90 static void DrawQuad(const Maths::Vec2& vertex1, const Maths::Vec2& vertex2, const Maths::Vec2& vertex3,
91 const Maths::Vec2& vertex4, const Maths::Vec3& color);
92
102 static void DrawLine(Maths::Vec2 start, Maths::Vec2 end, float thickness, Maths::Vec3 color);
103
112 static void DrawEllipse(Maths::Vec2 center, float radiusX, float radiusY, Maths::Vec3 color);
113
121 static void DrawCircle(Maths::Vec2 center, float radius, Maths::Vec3 color);
122 };
123}
This class provides an interface to draw 2D shapes.
Definition: Renderer2D.h:39
static void BeginScene()
Begins the scene.
Definition: Renderer2D.cpp:67
static void DrawEllipse(Maths::Vec2 center, float radiusX, float radiusY, Maths::Vec3 color)
Draws an ellipse.
Definition: Renderer2D.cpp:108
static void Init(int reserveVertices=10000)
Initializes the Renderer2D.
Definition: Renderer2D.cpp:9
static void EndScene()
Ends the scene.
Definition: Renderer2D.cpp:119
static void DrawLine(Maths::Vec2 start, Maths::Vec2 end, float thickness, Maths::Vec3 color)
Draws a line.
Definition: Renderer2D.cpp:98
static void DrawQuad(float x, float y, float width, float height, const Maths::Vec3 &color)
Draws a quad.
Definition: Renderer2D.cpp:87
static void DrawCircle(Maths::Vec2 center, float radius, Maths::Vec3 color)
Draws a circle.
Definition: Renderer2D.cpp:113
Contains a 2D vector.
Definition: Vec.h:108
Contains a 3D vector.
Definition: Vec.h:51
A struct that contains the data of the shapes.
Definition: Renderer2D.h:18