engine::graphics::Renderer class

Manages the graphics context and provides the core drawing API.

This is a singleton responsible for initializing GLAD and handling global rendering state.

The coordinate system by default has (0,0) at the bottom-left of the window, matching the default orthographic projection of the Camera.

Public static functions

static auto Get() -> Renderer&
Returns a reference to the singleton Renderer instance.

Public functions

void Clear() const
Clears the screen to the default background color.
void BeginFrame(Camera& camera) const
Prepares the renderer for a new frame.
void EndFrame() const
Finalizes the frame and presents the rendered image to the screen.
void DrawRect(float x, float y, float width, float height)
Draws a solid white rectangle to the screen.
void DrawRect(float x, float y, float width, float height, float r, float g, float b)
Draws a solid colored rectangle to the screen using RGB values.
void DrawQuad(const glm::vec2& position, const glm::vec2& size, const glm::vec4& color, float rotation = 0.0f, const glm::vec2& origin = {0.0f, 0.0f})
Draws a colored quad with full transformation support.
void DrawTexturedRect(float x, float y, float w, float h, unsigned int texture_id, const float tint[4] = nullptr)
Draws a textured rectangle to the screen.
void DrawTexturedQuad(const glm::vec2& position, const glm::vec2& size, unsigned int texture_id, float rotation = 0.0f, const glm::vec4& tint = glm::vec4(1.0f), const glm::vec2& origin = {0.0f, 0.0f})
Draws a textured quad with full transformation support.
void DrawTexturedQuad(const glm::vec2& position, const glm::vec2& size, const Texture* texture, float rotation = 0.0f, const glm::vec4& tint = glm::vec4(1.0f), const glm::vec2& origin = {0.0f, 0.0f})
Draws a textured quad with full transformation support.
void DrawText(const std::string& font_name, const std::string& text, const glm::vec2& position, float rotation = 0.0f, float scale = 1.0f, const glm::vec4& color = glm::vec4(1.0f))
Renders text with full transformation support.
auto ResolveAssetPath(const std::string& relative_path) const -> std::string
Takes a relative path and resolves to the full path.

Function documentation

static Renderer& engine::graphics::Renderer::Get()

Returns a reference to the singleton Renderer instance.

Returns Reference to the Renderer.

void engine::graphics::Renderer::BeginFrame(Camera& camera) const

Prepares the renderer for a new frame.

Parameters
camera The camera to use for this frame.

This should be called at the beginning of each frame's rendering phase.

void engine::graphics::Renderer::EndFrame() const

Finalizes the frame and presents the rendered image to the screen.

This should be called at the end of each frame's rendering phase.

void engine::graphics::Renderer::DrawRect(float x, float y, float width, float height)

Draws a solid white rectangle to the screen.

Parameters
x The x-coordinate of the bottom-left corner.
y The y-coordinate of the bottom-left corner.
width The width of the rectangle.
height The height of the rectangle.

void engine::graphics::Renderer::DrawRect(float x, float y, float width, float height, float r, float g, float b)

Draws a solid colored rectangle to the screen using RGB values.

Parameters
x The x-coordinate of the bottom-left corner.
y The y-coordinate of the bottom-left corner.
width The width of the rectangle.
height The height of the rectangle.
r The red component (0-1).
g The green component (0-1).
b The blue component (0-1).

void engine::graphics::Renderer::DrawQuad(const glm::vec2& position, const glm::vec2& size, const glm::vec4& color, float rotation = 0.0f, const glm::vec2& origin = {0.0f, 0.0f})

Draws a colored quad with full transformation support.

Parameters
position The world-space position.
size The width and height of the quad.
color The RGBA color.
rotation The rotation in degrees (counter-clockwise).
origin The origin point for rotation and positioning relative to size (e.g., (0,0) for bottom-left, (0.5, 0.5) for center).

void engine::graphics::Renderer::DrawTexturedRect(float x, float y, float w, float h, unsigned int texture_id, const float tint[4] = nullptr)

Draws a textured rectangle to the screen.

Parameters
x The x-coordinate of the bottom-left corner.
y The y-coordinate of the bottom-left corner.
w The width of the rectangle.
h The height of the rectangle.
texture_id The OpenGL ID of the texture.
tint Optional RGBA tint (defaults to white).

void engine::graphics::Renderer::DrawTexturedQuad(const glm::vec2& position, const glm::vec2& size, unsigned int texture_id, float rotation = 0.0f, const glm::vec4& tint = glm::vec4(1.0f), const glm::vec2& origin = {0.0f, 0.0f})

Draws a textured quad with full transformation support.

Parameters
position The world-space position.
size The width and height of the quad.
texture_id The OpenGL ID of the texture.
rotation The rotation in degrees (counter-clockwise).
tint The RGBA tint color.
origin The origin point for rotation and positioning relative to size (e.g., (0,0) for bottom-left, (0.5, 0.5) for center).

void engine::graphics::Renderer::DrawTexturedQuad(const glm::vec2& position, const glm::vec2& size, const Texture* texture, float rotation = 0.0f, const glm::vec4& tint = glm::vec4(1.0f), const glm::vec2& origin = {0.0f, 0.0f})

Draws a textured quad with full transformation support.

Parameters
position The world-space position.
size The width and height of the quad.
texture The Texture resource object.
rotation The rotation in degrees (counter-clockwise).
tint The RGBA tint color.
origin The origin point for rotation and positioning relative to size (e.g., (0,0) for bottom-left, (0.5, 0.5) for center).

void engine::graphics::Renderer::DrawText(const std::string& font_name, const std::string& text, const glm::vec2& position, float rotation = 0.0f, float scale = 1.0f, const glm::vec4& color = glm::vec4(1.0f))

Renders text with full transformation support.

Parameters
font_name The name of the loaded font.
text The string to render.
position The baseline origin of the text.
rotation The rotation in degrees (counter-clockwise).
scale The scale factor.
color The RGBA color.

std::string engine::graphics::Renderer::ResolveAssetPath(const std::string& relative_path) const

Takes a relative path and resolves to the full path.

Parameters
relative_path The relative path to resolve.
Returns The absolute path as a string.