Vivid
|
This class provides an interface to draw 2D shapes. More...
#include <Renderer2D.h>
Static Public Member Functions | |
static void | Init (int reserveVertices=10000) |
Initializes the Renderer2D. | |
static void | BeginScene () |
Begins the scene. | |
static void | EndScene () |
Ends the scene. | |
static void | DrawQuad (float x, float y, float width, float height, const Maths::Vec3 &color) |
Draws a quad. | |
static void | DrawQuad (const Maths::Vec2 &vertex1, const Maths::Vec2 &vertex2, const Maths::Vec2 &vertex3, const Maths::Vec2 &vertex4, const Maths::Vec3 &color) |
Draws a quad. | |
static void | DrawLine (Maths::Vec2 start, Maths::Vec2 end, float thickness, Maths::Vec3 color) |
Draws a line. | |
static void | DrawEllipse (Maths::Vec2 center, float radiusX, float radiusY, Maths::Vec3 color) |
Draws an ellipse. | |
static void | DrawCircle (Maths::Vec2 center, float radius, Maths::Vec3 color) |
Draws a circle. | |
This class provides an interface to draw 2D shapes.
This class provides an interface to draw 2D shapes like quads, lines, ellipses, and circles. All the functions are static, so you don't need to create an instance of this class to use it. It uses the
Definition at line 38 of file Renderer2D.h.
|
static |
Begins the scene.
Begins the scene by binding the VertexArray and the shaders.
Definition at line 67 of file Renderer2D.cpp.
|
static |
Draws a circle.
Draws a circle with the specified center, radius, and color. This is also a quad and is draw using a shader that makes it look like a circle.
center | The center of the circle. |
radius | The radius of the circle. |
color | The color of the circle. |
Definition at line 113 of file Renderer2D.cpp.
|
static |
Draws an ellipse.
Draws an ellipse with the specified center, radiusX, radiusY, and color. This is also a quad and is draw using a shader that makes it look like an ellipse.
center | The center of the ellipse. |
radiusX | The radius of the ellipse in the x-axis. |
radiusY | The radius of the ellipse in the y-axis. |
color | The color of the ellipse. |
Definition at line 108 of file Renderer2D.cpp.
|
static |
Draws a line.
Draws a line with the specified vertices and color. The line is drawn using a line shader. Which is a essentially a small quad with anti aliasing, to make the line look smooth.
start | The first vertex of the line. |
end | The second vertex of the line. |
thickness | The thickness of the line. |
color | The color of the line. |
Definition at line 98 of file Renderer2D.cpp.
|
static |
Draws a quad.
Draws a quad with the specified vertices and color. The order of the vertices is important. The quad is drawn in the order vertex1, vertex2, vertex3, vertex4.
vertex1 | The first vertex of the quad. |
vertex2 | The second vertex of the quad. |
vertex3 | The third vertex of the quad. |
vertex4 | The fourth vertex of the quad. |
color | The color of the quad. |
Definition at line 92 of file Renderer2D.cpp.
|
static |
Draws a quad.
Draws a quad with specified center-positon, size, and color.
x | The x-coordinate of the center of the quad. |
y | The y-coordinate of the center of the quad. |
width | The width of the quad. |
height | The height of the quad. |
color | The color of the quad. |
Definition at line 87 of file Renderer2D.cpp.
|
static |
Ends the scene.
Ends the scene by unbinding the VertexArray and the shaders. This is where the actual draw call is made.
Definition at line 119 of file Renderer2D.cpp.
|
static |
Initializes the Renderer2D.
Initializes the Renderer2D by creating the VertexArray, the shaders, and the vertices and indices of the shapes.
reserveVertices | The number of vertices to reserve. |
Definition at line 9 of file Renderer2D.cpp.