Vivid
Loading...
Searching...
No Matches
Vivid::Renderer2D Class Reference

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.
 

Detailed Description

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.

Member Function Documentation

◆ BeginScene()

void Vivid::Renderer2D::BeginScene ( )
static

Begins the scene.

Begins the scene by binding the VertexArray and the shaders.

Definition at line 67 of file Renderer2D.cpp.

◆ DrawCircle()

void Vivid::Renderer2D::DrawCircle ( Maths::Vec2  center,
float  radius,
Maths::Vec3  color 
)
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.

Parameters
centerThe center of the circle.
radiusThe radius of the circle.
colorThe color of the circle.

Definition at line 113 of file Renderer2D.cpp.

◆ DrawEllipse()

void Vivid::Renderer2D::DrawEllipse ( Maths::Vec2  center,
float  radiusX,
float  radiusY,
Maths::Vec3  color 
)
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.

Parameters
centerThe center of the ellipse.
radiusXThe radius of the ellipse in the x-axis.
radiusYThe radius of the ellipse in the y-axis.
colorThe color of the ellipse.

Definition at line 108 of file Renderer2D.cpp.

◆ DrawLine()

void Vivid::Renderer2D::DrawLine ( Maths::Vec2  start,
Maths::Vec2  end,
float  thickness,
Maths::Vec3  color 
)
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.

Parameters
startThe first vertex of the line.
endThe second vertex of the line.
thicknessThe thickness of the line.
colorThe color of the line.

Definition at line 98 of file Renderer2D.cpp.

◆ DrawQuad() [1/2]

void Vivid::Renderer2D::DrawQuad ( const Maths::Vec2 vertex1,
const Maths::Vec2 vertex2,
const Maths::Vec2 vertex3,
const Maths::Vec2 vertex4,
const Maths::Vec3 color 
)
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.

Parameters
vertex1The first vertex of the quad.
vertex2The second vertex of the quad.
vertex3The third vertex of the quad.
vertex4The fourth vertex of the quad.
colorThe color of the quad.

Definition at line 92 of file Renderer2D.cpp.

◆ DrawQuad() [2/2]

void Vivid::Renderer2D::DrawQuad ( float  x,
float  y,
float  width,
float  height,
const Maths::Vec3 color 
)
static

Draws a quad.

Draws a quad with specified center-positon, size, and color.

Parameters
xThe x-coordinate of the center of the quad.
yThe y-coordinate of the center of the quad.
widthThe width of the quad.
heightThe height of the quad.
colorThe color of the quad.

Definition at line 87 of file Renderer2D.cpp.

◆ EndScene()

void Vivid::Renderer2D::EndScene ( )
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.

◆ Init()

void Vivid::Renderer2D::Init ( int  reserveVertices = 10000)
static

Initializes the Renderer2D.

Initializes the Renderer2D by creating the VertexArray, the shaders, and the vertices and indices of the shapes.

Parameters
reserveVerticesThe number of vertices to reserve.

Definition at line 9 of file Renderer2D.cpp.


The documentation for this class was generated from the following files: