3D Graphics Engine for ESP32
 
Loading...
Searching...
No Matches
Ragot::Renderer Class Reference

Class for rendering scenes in the Ragot engine. More...

#include <Renderer.hpp>

Collaboration diagram for Ragot::Renderer:
Collaboration graph

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_ProgramquadShader = 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< RGB565frame_buffer
 Frame buffer for rendering, used to store pixel data for the rendered scene.
 
Scenecurrent_scene = nullptr
 Pointer to the current scene being rendered, allows access to scene data and objects.
 
Rasterizer< RGB565rasterizer
 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Renderer() [1/2]

Ragot::Renderer::Renderer ( )
delete

Construct a new Renderer object (Deleted).

This constructor is deleted to prevent default construction of the Renderer class.

◆ Renderer() [2/2]

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.

Parameters
widthThe width of the rendering area in pixels.
heightThe height of the rendering area in pixels.
Here is the call graph for this function:

◆ ~Renderer()

Ragot::Renderer::~Renderer ( )
default

Default destructor for the Renderer class.

Cleans up resources used by the renderer.

Member Function Documentation

◆ init()

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.

Returns
Scene* Pointer to the current Scene object.
Here is the caller graph for this function:

◆ initFullScreenQuad()

void Ragot::Renderer::initFullScreenQuad ( )
private

Initializes the full-screen quad for rendering, used in non-ESP platforms.

Here is the caller graph for this function:

◆ is_frontface()

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.

Parameters
projected_verticesPointer to an array of projected vertices in clip space.
indicesPointer to the face structure containing vertex indices.
Returns
true if the face is front-facing, false otherwise.

◆ render()

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.

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

◆ set_scene()

void Ragot::Renderer::set_scene ( Scene * scene)
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.

Parameters
scenePointer to the Scene object to be set as the current scene.
Here is the caller graph for this function:

◆ start()

void Ragot::Renderer::start ( )
inline

Starts the rendering process.

This method sets the running flag to true, indicating that the renderer is ready to start rendering.

Here is the caller graph for this function:

◆ stop()

void Ragot::Renderer::stop ( )
inline

Stops the rendering process.

This method sets the running flag to false, indicating that the renderer should stop rendering.

◆ task_render()

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.

Parameters
stop_token
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ accumulated_time

float Ragot::Renderer::accumulated_time = 0.f
private

Accumulated time for rendering frames, used for timing and performance measurement.

◆ current_scene

Scene* Ragot::Renderer::current_scene = nullptr
private

Pointer to the current scene being rendered, allows access to scene data and objects.

◆ display_vertices

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.

◆ fragment_shader_code

const string Ragot::Renderer::fragment_shader_code
staticprivate
Initial value:
=
"#version 330\n"
"in vec2 vTex;"
"out vec4 FragColor;"
""
"uniform sampler2D uSampler;"
""
"void main()"
"{"
" FragColor = texture(uSampler, vTex);"
"}"

Fragment shader code for rendering, used in non-ESP platforms.

◆ frame_buffer

FrameBuffer< RGB565 > Ragot::Renderer::frame_buffer
private

Frame buffer for rendering, used to store pixel data for the rendered scene.

◆ height

unsigned Ragot::Renderer::height
private

Height of the rendering area in pixels, used to define the size of the frame buffer and viewport.

◆ initialized

bool Ragot::Renderer::initialized = false
private

Flag to indicate if the renderer has been initialized, used to prevent re-initialization and ensure resources are set up correctly.

◆ iterations

size_t Ragot::Renderer::iterations = 0
private

Number of iterations for rendering, used for performance testing and optimization.

◆ number_of_iterations

size_t Ragot::Renderer::number_of_iterations = 10000000000000000
staticconstexprprivate

◆ quadEBO

GLuint Ragot::Renderer::quadEBO = 0
private

Element Buffer Object for the full-screen quad, used in non-ESP platforms.

◆ quadShader

std::unique_ptr< Shader_Program > Ragot::Renderer::quadShader = nullptr
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.

◆ quadVAO

GLuint Ragot::Renderer::quadVAO = 0
private

Vertex Array Object for the full-screen quad, used in non-ESP platforms.

◆ quadVBO

GLuint Ragot::Renderer::quadVBO = 0
private

Vertex Buffer Object for the full-screen quad, used in non-ESP platforms.

◆ rasterizer

Rasterizer< RGB565 > Ragot::Renderer::rasterizer
private

Rasterizer for rendering polygons in the frame buffer, responsible for filling polygons with color and handling depth testing.

◆ running

std::atomic<bool> Ragot::Renderer::running = false
private

Flag to indicate if the renderer is currently running, used to control rendering tasks and stop them gracefully.

◆ transformed_vertices

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.

◆ vertex_shader_code

const string Ragot::Renderer::vertex_shader_code
staticprivate
Initial value:
=
"#version 330\n"
"layout(location = 0) in vec2 aPos;"
"layout(location = 1) in vec2 aTex;"
""
"out vec2 vTex;"
""
"void main()"
"{"
" vTex = aTex;"
" gl_Position = vec4(aPos, 0.0, 1.0);"
"}"

Vertex shader code for rendering, used in non-ESP platforms.

◆ width

unsigned Ragot::Renderer::width
private

Width of the rendering area in pixels, used to define the size of the frame buffer and viewport.


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