galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::graphics::Renderer Class Referencefinal

2D OpenGL renderer. More...

#include <Renderer.hpp>

+ Collaboration diagram for galaxy::graphics::Renderer:

Public Member Functions

void init ()
 Initialize renderer.
 
void destroy ()
 Cleanup renderer data.
 
void on_window_resized (const events::WindowResized &e)
 Event processing method for window size change.
 
void submit_camera (Camera &camera)
 Set the camera to use when calling draw().
 
void submit_cmd (RenderCommand &command)
 Add an entity rendering command.
 
void submit_texture (const Texture2D &texture, VertexArray &va, Transform &tf, const int layer, const float opacity)
 Submit a standalone texture to be rendered.
 
void submit_text (Text &text, Transform &tf, const int layer)
 Submit standalone text to be rendered.
 
void submit_shape (Shape *shape, Transform &tf, const int layer)
 Submit a standalone shape to be rendered.
 
void draw_texture_to_target (RenderTexture &target, Texture *texture, VertexArray &va, Transform &tf)
 Draw a texture to a render texture.
 
void draw ()
 Draw all submitted render commands to screen.
 
void flush ()
 Deletes all submitted render commands.
 
void clear_active ()
 Clears currently active framebuffer.
 
void begin_post ()
 Begin rendering to post process framebuffer.
 
void end_post ()
 Renders effects to post processing framebuffer and rebinds to default framebuffer.
 
void render_post ()
 Renders final post processing output to active framebuffer.
 
void begin_default ()
 Start rendering to default framebuffer.
 
void end_default ()
 Swaps buffers.
 

Static Public Member Functions

static Rendererref ()
 Get reference to renderer singleton.
 

Private Member Functions

 Renderer ()
 Constructor.
 
 ~Renderer ()=default
 Destructor.
 
void calc_viewport (int window_width, int window_height)
 Need to recalculate default framebuffer viewport.
 

Private Attributes

meta::vector< RenderCommandm_cmds
 List of renderables to draw.
 
Shader m_r2d_shader
 Mono render shader.
 
ShaderStorageBuffer m_camera
 Camera buffer storage.
 
ShaderStorageBuffer m_renderdata
 Uniform buffer storage.
 
PostProcess m_post
 Post processor.
 
glm::vec4 m_viewport
 Default framebuffer viewport.
 

Detailed Description

2D OpenGL renderer.

Definition at line 32 of file Renderer.hpp.

Constructor & Destructor Documentation

◆ Renderer()

galaxy::graphics::Renderer::Renderer ( )
private

Constructor.

Definition at line 25 of file Renderer.cpp.

◆ ~Renderer()

galaxy::graphics::Renderer::~Renderer ( )
privatedefault

Destructor.

Member Function Documentation

◆ ref()

Renderer & galaxy::graphics::Renderer::ref ( )
staticnodiscard

Get reference to renderer singleton.

Returns
Static reference.

Definition at line 19 of file Renderer.cpp.

+ Here is the caller graph for this function:

◆ init()

void galaxy::graphics::Renderer::init ( )

Initialize renderer.

Definition at line 31 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ destroy()

void galaxy::graphics::Renderer::destroy ( )

Cleanup renderer data.

Definition at line 62 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ on_window_resized()

void galaxy::graphics::Renderer::on_window_resized ( const events::WindowResized & e)

Event processing method for window size change.

Parameters
eTakes in a window resized event.

Definition at line 71 of file Renderer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ submit_camera()

void galaxy::graphics::Renderer::submit_camera ( Camera & camera)

Set the camera to use when calling draw().

Parameters
cameraCamera object to buffer.

Definition at line 76 of file Renderer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ submit_cmd()

void galaxy::graphics::Renderer::submit_cmd ( RenderCommand & command)

Add an entity rendering command.

Parameters
commandRendering command to draw.

Definition at line 81 of file Renderer.cpp.

+ Here is the caller graph for this function:

◆ submit_texture()

void galaxy::graphics::Renderer::submit_texture ( const Texture2D & texture,
VertexArray & va,
Transform & tf,
const int layer,
const float opacity )

Submit a standalone texture to be rendered.

Parameters
textureTexture to use when drawing.
vaVertex data to use when drawing.
tfObject transformation.
layerRendering z-level layer.
opacityObject opacity.

Definition at line 86 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ submit_text()

void galaxy::graphics::Renderer::submit_text ( Text & text,
Transform & tf,
const int layer )

Submit standalone text to be rendered.

Parameters
textText to draw.
tfObject transformation.
layerRendering z-level layer.

Definition at line 106 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ submit_shape()

void galaxy::graphics::Renderer::submit_shape ( Shape * shape,
Transform & tf,
const int layer )

Submit a standalone shape to be rendered.

Parameters
shapePolymorphic shape to render.
tfObject transformation.
layerRendering z-level layer.

Definition at line 126 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ draw_texture_to_target()

void galaxy::graphics::Renderer::draw_texture_to_target ( RenderTexture & target,
Texture * texture,
VertexArray & va,
Transform & tf )

Draw a texture to a render texture.

Standalone function.

Parameters
targetTarget to draw texture to.
textureTexture to draw to the target.
vaVertex array object.
transformOrthographic transform.

Definition at line 146 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ draw()

void galaxy::graphics::Renderer::draw ( )

Draw all submitted render commands to screen.

Definition at line 166 of file Renderer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flush()

void galaxy::graphics::Renderer::flush ( )

Deletes all submitted render commands.

Definition at line 189 of file Renderer.cpp.

+ Here is the caller graph for this function:

◆ clear_active()

void galaxy::graphics::Renderer::clear_active ( )

Clears currently active framebuffer.

Definition at line 194 of file Renderer.cpp.

+ Here is the caller graph for this function:

◆ begin_post()

void galaxy::graphics::Renderer::begin_post ( )

Begin rendering to post process framebuffer.

Definition at line 200 of file Renderer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end_post()

void galaxy::graphics::Renderer::end_post ( )

Renders effects to post processing framebuffer and rebinds to default framebuffer.

Definition at line 206 of file Renderer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render_post()

void galaxy::graphics::Renderer::render_post ( )

Renders final post processing output to active framebuffer.

Definition at line 212 of file Renderer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ begin_default()

void galaxy::graphics::Renderer::begin_default ( )

Start rendering to default framebuffer.

This should be called at the end of rendering, only rendering your final framebuffer, since afterwards we swap buffers.

Definition at line 217 of file Renderer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end_default()

void galaxy::graphics::Renderer::end_default ( )

Swaps buffers.

Definition at line 238 of file Renderer.cpp.

+ Here is the caller graph for this function:

◆ calc_viewport()

void galaxy::graphics::Renderer::calc_viewport ( int window_width,
int window_height )
private

Need to recalculate default framebuffer viewport.

Parameters
window_widthNew window width.
window_heightNew window height.

Definition at line 243 of file Renderer.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_cmds

meta::vector<RenderCommand> galaxy::graphics::Renderer::m_cmds
private

List of renderables to draw.

Definition at line 179 of file Renderer.hpp.

◆ m_r2d_shader

Shader galaxy::graphics::Renderer::m_r2d_shader
private

Mono render shader.

Definition at line 184 of file Renderer.hpp.

◆ m_camera

ShaderStorageBuffer galaxy::graphics::Renderer::m_camera
private

Camera buffer storage.

Definition at line 189 of file Renderer.hpp.

◆ m_renderdata

ShaderStorageBuffer galaxy::graphics::Renderer::m_renderdata
private

Uniform buffer storage.

Definition at line 194 of file Renderer.hpp.

◆ m_post

PostProcess galaxy::graphics::Renderer::m_post
private

Post processor.

Definition at line 199 of file Renderer.hpp.

◆ m_viewport

glm::vec4 galaxy::graphics::Renderer::m_viewport
private

Default framebuffer viewport.

Definition at line 204 of file Renderer.hpp.


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