BARE2D
BARE2D::DebugRenderer Class Reference

#include <DebugRenderer.hpp>

+ Inheritance diagram for BARE2D::DebugRenderer:
+ Collaboration diagram for BARE2D::DebugRenderer:

Public Member Functions

 DebugRenderer ()
 
virtual ~DebugRenderer ()
 
virtual void init () override
 Initializes with very rudimentary shaders (hardcoded), adds vertex attributes. More...
 
virtual void begin () override
 Clears the necessary vectors, etc. to prepare for draw() calls, etc. More...
 
virtual void render () override
 Actually renders the contents to the screen! More...
 
virtual void drawLine (glm::vec2 point0, glm::vec2 point1, float thickness, Colour colour)
 Draws a line. More...
 
virtual void drawCircle (glm::vec2 centre, float lineThickness, float radius, Colour fillColour=Colour(255, 255, 255, 255))
 Draws a circle. More...
 
virtual void drawRectangle (glm::vec4 destRect, float lineThickness, Colour fillColour=Colour(255, 255, 255, 255))
 Draws a rectangle. More...
 
- Public Member Functions inherited from BARE2D::Renderer
 Renderer ()
 
virtual ~Renderer ()
 
virtual void end ()
 Creates the renderbatches, does necessary stuff before render() call. More...
 
virtual void initUniforms ()
 Initializes all uniforms, such as colour attachments, depth attachments, etc. More...
 
virtual void destroy ()
 Frees all necessary memory. More...
 
ShaderProgramgetShader ()
 

Protected Member Functions

virtual void createRenderBatches () override
 Constructs all of the render batches from data given by, say, draw() calls. More...
 
- Protected Member Functions inherited from BARE2D::Renderer
virtual void preRender ()
 Does stuff inside of the render function, within the shader's use. More...
 
virtual void link (std::initializer_list< std::string > attributes)
 

Protected Attributes

std::vector< Linem_lines
 
std::vector< Circlem_circles
 
std::vector< Rectanglem_rectangles
 
- Protected Attributes inherited from BARE2D::Renderer
ShaderProgram m_shader
 
VAO m_vertexArrayObject
 
std::vector< RenderBatchm_batches
 

Detailed Description

Author
Davis-Dev
Date
10/08/23

Definition at line 42 of file DebugRenderer.hpp.

Constructor & Destructor Documentation

◆ DebugRenderer()

BARE2D::DebugRenderer::DebugRenderer ( )

Definition at line 68 of file DebugRenderer.cpp.

◆ ~DebugRenderer()

BARE2D::DebugRenderer::~DebugRenderer ( )
virtual

Definition at line 71 of file DebugRenderer.cpp.

Member Function Documentation

◆ begin()

void BARE2D::DebugRenderer::begin ( )
overridevirtual

Clears the necessary vectors, etc. to prepare for draw() calls, etc.

Reimplemented from BARE2D::Renderer.

Definition at line 90 of file DebugRenderer.cpp.

References BARE2D::Renderer::begin(), m_circles, m_lines, and m_rectangles.

+ Here is the call graph for this function:

◆ createRenderBatches()

void BARE2D::DebugRenderer::createRenderBatches ( )
overrideprotectedvirtual

Constructs all of the render batches from data given by, say, draw() calls.

Implements BARE2D::Renderer.

Definition at line 113 of file DebugRenderer.cpp.

References BARE2D::VAO::bindVBO(), CIRCLE_LINES, m_circles, m_lines, m_rectangles, and BARE2D::Renderer::m_vertexArrayObject.

+ Here is the call graph for this function:

◆ drawCircle()

void BARE2D::DebugRenderer::drawCircle ( glm::vec2  centre,
float  lineThickness,
float  radius,
Colour  fillColour = Colour(255, 255, 255, 255) 
)
virtual

Draws a circle.

Parameters
centreThe centre point of the circle
lineThicknessThe thickness of the lines creating the circle
radiusThe radius of the circle
lineColourThe colour of the lines
fillColourThe fill of the circle

Definition at line 103 of file DebugRenderer.cpp.

References m_circles.

◆ drawLine()

void BARE2D::DebugRenderer::drawLine ( glm::vec2  point0,
glm::vec2  point1,
float  thickness,
Colour  colour 
)
virtual

Draws a line.

Parameters
point0The origin
point1Where the line goes to
thicknessThe thickness of the line
colourThe colour of the line

Definition at line 98 of file DebugRenderer.cpp.

References m_lines.

◆ drawRectangle()

void BARE2D::DebugRenderer::drawRectangle ( glm::vec4  destRect,
float  lineThickness,
Colour  fillColour = Colour(255, 255, 255, 255) 
)
virtual

Draws a rectangle.

Parameters
destRectThe destination rectangle of the rectangle (position, then size)
lineColourThe colour of the lines that make up the rectangle
fillColourThe colour of the fill.

Definition at line 108 of file DebugRenderer.cpp.

References m_rectangles.

◆ init()

void BARE2D::DebugRenderer::init ( )
overridevirtual

Initializes with very rudimentary shaders (hardcoded), adds vertex attributes.

Reimplemented from BARE2D::Renderer.

Definition at line 74 of file DebugRenderer.cpp.

References BARE2D::VAO::addVertexAttribute(), BARE2D::ShaderProgram::compileShadersFromSource(), fragShaderSource, BARE2D::Renderer::init(), BARE2D::Renderer::link(), BARE2D::Renderer::m_shader, BARE2D::Renderer::m_vertexArrayObject, and vertShaderSource.

+ Here is the call graph for this function:

◆ render()

void BARE2D::DebugRenderer::render ( )
overridevirtual

Field Documentation

◆ m_circles

std::vector<Circle> BARE2D::DebugRenderer::m_circles
protected

Definition at line 87 of file DebugRenderer.hpp.

Referenced by begin(), createRenderBatches(), drawCircle(), and render().

◆ m_lines

std::vector<Line> BARE2D::DebugRenderer::m_lines
protected

Definition at line 86 of file DebugRenderer.hpp.

Referenced by begin(), createRenderBatches(), drawLine(), and render().

◆ m_rectangles

std::vector<Rectangle> BARE2D::DebugRenderer::m_rectangles
protected

Definition at line 88 of file DebugRenderer.hpp.

Referenced by begin(), createRenderBatches(), drawRectangle(), and render().


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