Class for rendering scenes in the Ragot engine. More...
#include <Renderer.hpp>
Public Member Functions | |
Renderer ()=delete | |
Construct a new Renderer object (Deleted). | |
Renderer (unsigned width, unsigned height) | |
Constructs a Renderer with the specified width and height. | |
~Renderer ()=default | |
Default destructor for the Renderer class. | |
void | set_scene (Scene *scene) |
Sets the current scene to be rendered. | |
void | init () |
Gets the current scene being rendered. | |
void | render () |
Renders the current scene. | |
void | task_render (std::stop_token stop_token) |
Performs the rendering task in a separate thread. | |
bool | is_frontface (const glm::fvec4 *const projected_vertices, const face_t *const indices) |
Checks if the face defined by the indices is front-facing. | |
void | start () |
Starts the rendering process. | |
void | stop () |
Stops the rendering process. | |
Public Attributes | |
std::vector< glm::fvec4 > | transformed_vertices |
Vector to store transformed vertices for rendering, used to hold the vertices after applying transformations such as model, view, and projection matrices. | |
std::vector< glm::ivec4 > | display_vertices |
Vector to store display vertices for rendering, used to hold the vertices after applying viewport transformations and clipping. | |
Private Member Functions | |
void | initFullScreenQuad () |
Initializes the full-screen quad for rendering, used in non-ESP platforms. | |
Private Attributes | |
float | accumulated_time = 0.f |
Accumulated time for rendering frames, used for timing and performance measurement. | |
size_t | iterations = 0 |
Number of iterations for rendering, used for performance testing and optimization. | |
std::unique_ptr< Shader_Program > | quadShader = nullptr |
Number of iterations for performance testing, can be adjusted for different scenarios. | |
GLuint | quadVAO = 0 |
Vertex Array Object for the full-screen quad, used in non-ESP platforms. | |
GLuint | quadVBO = 0 |
Vertex Buffer Object for the full-screen quad, used in non-ESP platforms. | |
GLuint | quadEBO = 0 |
Element Buffer Object for the full-screen quad, used in non-ESP platforms. | |
FrameBuffer< RGB565 > | frame_buffer |
Frame buffer for rendering, used to store pixel data for the rendered scene. | |
Scene * | current_scene = nullptr |
Pointer to the current scene being rendered, allows access to scene data and objects. | |
Rasterizer< RGB565 > | rasterizer |
Rasterizer for rendering polygons in the frame buffer, responsible for filling polygons with color and handling depth testing. | |
unsigned | width |
Width of the rendering area in pixels, used to define the size of the frame buffer and viewport. | |
unsigned | height |
Height of the rendering area in pixels, used to define the size of the frame buffer and viewport. | |
bool | initialized = false |
Flag to indicate if the renderer has been initialized, used to prevent re-initialization and ensure resources are set up correctly. | |
std::atomic< bool > | running = false |
Flag to indicate if the renderer is currently running, used to control rendering tasks and stop them gracefully. | |
Static Private Attributes | |
static constexpr size_t | number_of_iterations = 10000000000000000 |
static const std::string | vertex_shader_code |
Vertex shader code for rendering, used in non-ESP platforms. | |
static const std::string | fragment_shader_code |
Fragment shader code for rendering, used in non-ESP platforms. | |
Class for rendering scenes in the Ragot engine.
This class is responsible for rendering 3D scenes using a rasterization approach. It manages the frame buffer, rasterizer, and scene to be rendered.
|
delete |
Ragot::Renderer::Renderer | ( | unsigned | width, |
unsigned | height ) |
Constructs a Renderer with the specified width and height.
Initializes the renderer with the given dimensions and prepares the frame buffer and rasterizer.
width | The width of the rendering area in pixels. |
height | The height of the rendering area in pixels. |
|
default |
Default destructor for the Renderer class.
Cleans up resources used by the renderer.
void Ragot::Renderer::init | ( | ) |
Gets the current scene being rendered.
This method returns a pointer to the current scene being rendered by the renderer. It allows access to the scene's objects and properties for rendering.
|
private |
Initializes the full-screen quad for rendering, used in non-ESP platforms.
bool Ragot::Renderer::is_frontface | ( | const glm::fvec4 *const | projected_vertices, |
const face_t *const | indices ) |
Checks if the face defined by the indices is front-facing.
This method checks if the face defined by the indices is front-facing based on the projected vertices. It uses the area of the face to determine its orientation.
projected_vertices | Pointer to an array of projected vertices in clip space. |
indices | Pointer to the face structure containing vertex indices. |
void Ragot::Renderer::render | ( | ) |
Renders the current scene.
This method performs the rendering of the current scene by preparing matrices, transforming vertices, and filling polygons in the frame buffer using the rasterizer. It also handles depth testing and color filling for polygons.
|
inline |
Sets the current scene to be rendered.
This method sets the current scene to be rendered by the renderer. It allows the renderer to access the scene's objects and properties for rendering.
scene | Pointer to the Scene object to be set as the current scene. |
|
inline |
Starts the rendering process.
This method sets the running flag to true, indicating that the renderer is ready to start rendering.
|
inline |
Stops the rendering process.
This method sets the running flag to false, indicating that the renderer should stop rendering.
void Ragot::Renderer::task_render | ( | std::stop_token | stop_token | ) |
Performs the rendering task in a separate thread.
This method runs the rendering task in a separate thread, allowing for asynchronous rendering.
stop_token |
|
private |
Accumulated time for rendering frames, used for timing and performance measurement.
|
private |
Pointer to the current scene being rendered, allows access to scene data and objects.
std::vector< glm::ivec4 > Ragot::Renderer::display_vertices |
Vector to store display vertices for rendering, used to hold the vertices after applying viewport transformations and clipping.
|
staticprivate |
Fragment shader code for rendering, used in non-ESP platforms.
|
private |
Frame buffer for rendering, used to store pixel data for the rendered scene.
|
private |
Height of the rendering area in pixels, used to define the size of the frame buffer and viewport.
|
private |
Flag to indicate if the renderer has been initialized, used to prevent re-initialization and ensure resources are set up correctly.
|
private |
Number of iterations for rendering, used for performance testing and optimization.
|
staticconstexprprivate |
|
private |
Element Buffer Object for the full-screen quad, used in non-ESP platforms.
|
private |
Number of iterations for performance testing, can be adjusted for different scenarios.
Shader program for rendering a full-screen quad, used in non-ESP platforms.
|
private |
Vertex Array Object for the full-screen quad, used in non-ESP platforms.
|
private |
Vertex Buffer Object for the full-screen quad, used in non-ESP platforms.
|
private |
Rasterizer for rendering polygons in the frame buffer, responsible for filling polygons with color and handling depth testing.
|
private |
Flag to indicate if the renderer is currently running, used to control rendering tasks and stop them gracefully.
std::vector< glm::fvec4 > Ragot::Renderer::transformed_vertices |
Vector to store transformed vertices for rendering, used to hold the vertices after applying transformations such as model, view, and projection matrices.
|
staticprivate |
Vertex shader code for rendering, used in non-ESP platforms.
|
private |
Width of the rendering area in pixels, used to define the size of the frame buffer and viewport.