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
Renderer.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_GRAPHICS_RENDERER_HPP_
9#define GALAXY_GRAPHICS_RENDERER_HPP_
10
23#include "galaxy/meta/Memory.hpp"
24
25namespace galaxy
26{
27 namespace graphics
28 {
32 class Renderer final
33 {
34 public:
40 [[nodiscard]]
41 static Renderer& ref();
42
46 void init();
47
51 void destroy();
52
58 void on_window_resized(const events::WindowResized& e);
59
65 void submit_camera(Camera& camera);
66
72 void submit_cmd(RenderCommand& command);
73
83 void submit_texture(const Texture2D& texture, VertexArray& va, Transform& tf, const int layer, const float opacity);
84
92 void submit_text(Text& text, Transform& tf, const int layer);
93
101 void submit_shape(Shape* shape, Transform& tf, const int layer);
102
113 void draw_texture_to_target(RenderTexture& target, Texture* texture, VertexArray& va, Transform& tf);
114
118 void draw();
119
123 void flush();
124
128 void clear_active();
129
133 void begin_post();
134
138 void end_post();
139
143 void render_post();
144
150 void begin_default();
151
155 void end_default();
156
157 private:
161 Renderer();
162
166 ~Renderer() = default;
167
173 void calc_viewport(int window_width, int window_height);
174
175 private:
179 meta::vector<RenderCommand> m_cmds;
180
185
190
195
200
204 glm::vec4 m_viewport;
205 };
206 } // namespace graphics
207} // namespace galaxy
208
209#endif
Orthographic 2D camera.
Definition Camera.hpp:28
Manages post processing effects to apply to combined scene.
Draw to an opengl texture instead of the screen.
2D OpenGL renderer.
Definition Renderer.hpp:33
void submit_text(Text &text, Transform &tf, const int layer)
Submit standalone text to be rendered.
Definition Renderer.cpp:106
meta::vector< RenderCommand > m_cmds
List of renderables to draw.
Definition Renderer.hpp:179
glm::vec4 m_viewport
Default framebuffer viewport.
Definition Renderer.hpp:204
void end_default()
Swaps buffers.
Definition Renderer.cpp:238
void submit_texture(const Texture2D &texture, VertexArray &va, Transform &tf, const int layer, const float opacity)
Submit a standalone texture to be rendered.
Definition Renderer.cpp:86
void begin_post()
Begin rendering to post process framebuffer.
Definition Renderer.cpp:200
void render_post()
Renders final post processing output to active framebuffer.
Definition Renderer.cpp:212
ShaderStorageBuffer m_renderdata
Uniform buffer storage.
Definition Renderer.hpp:194
void end_post()
Renders effects to post processing framebuffer and rebinds to default framebuffer.
Definition Renderer.cpp:206
void clear_active()
Clears currently active framebuffer.
Definition Renderer.cpp:194
PostProcess m_post
Post processor.
Definition Renderer.hpp:199
~Renderer()=default
Destructor.
void flush()
Deletes all submitted render commands.
Definition Renderer.cpp:189
void submit_cmd(RenderCommand &command)
Add an entity rendering command.
Definition Renderer.cpp:81
void submit_camera(Camera &camera)
Set the camera to use when calling draw().
Definition Renderer.cpp:76
void init()
Initialize renderer.
Definition Renderer.cpp:31
void draw()
Draw all submitted render commands to screen.
Definition Renderer.cpp:166
static Renderer & ref()
Get reference to renderer singleton.
Definition Renderer.cpp:19
Shader m_r2d_shader
Mono render shader.
Definition Renderer.hpp:184
void submit_shape(Shape *shape, Transform &tf, const int layer)
Submit a standalone shape to be rendered.
Definition Renderer.cpp:126
void destroy()
Cleanup renderer data.
Definition Renderer.cpp:62
void draw_texture_to_target(RenderTexture &target, Texture *texture, VertexArray &va, Transform &tf)
Draw a texture to a render texture.
Definition Renderer.cpp:146
void calc_viewport(int window_width, int window_height)
Need to recalculate default framebuffer viewport.
Definition Renderer.cpp:243
void begin_default()
Start rendering to default framebuffer.
Definition Renderer.cpp:217
ShaderStorageBuffer m_camera
Camera buffer storage.
Definition Renderer.hpp:189
void on_window_resized(const events::WindowResized &e)
Event processing method for window size change.
Definition Renderer.cpp:71
Abstraction for OpenGL buffer objects.
OpenGL Shader Program.
Definition Shader.hpp:29
A generic 2D shape.
Definition Shape.hpp:22
String of glyphs rendered with a font.
Definition Text.hpp:23
Standard opengl texture.
Definition Texture2D.hpp:21
OpenGL 2D Texture.
Definition Texture.hpp:26
Defines the 2D transformation of an entity.
Definition Transform.hpp:21
Abstraction for OpenGL vertex array objects.
Animated.cpp galaxy.
Definition Animated.cpp:16
Data to be passed to the renderer.