Particle​ Simulation Documentation
Loading...
Searching...
No Matches
Renderer Class Reference

#include <renderer.h>

Collaboration diagram for Renderer:

Public Member Functions

 Renderer (const Config &config)
 Initialize renderer. This method setup the GLFW library for rendering the scene and the Dear ImGui library for rendering the Graphical user interface.
 
 ~Renderer ()
 Destroys the renderer.
 
void initializeGLFW ()
 Initializes the GLFW library. This method is called by the constructor.
 
void framebufferSizeCallback (int width, int height)
 Define Callback for window framebuffer size. This method is a callback function given to GLFW via glfwSetFramebufferSizeCallback in initializeGLFW. This method will be called automatically each time the window's framebuffer size change.
 
void cursorPosCallback (double xpos, double ypos)
 Define Callback for cursor position.
 
void keyboardCallback (int key, int scancode, int action, int mods)
 Define Callback for Keyboard inputs.
 
void initializeImGui ()
 Initializes the Dear ImGui library. This method is called by the constructor.
 
void initializeImPlot ()
 Initializes the imPlot library. This method is called by the constructor.
 
void render (Universe &universe)
 Renders the given universe.
 
void renderParticleTrail (const Particle &particle)
 Render the trail of the given particle.
 
void drawBoxes ()
 Draws the m_boxes boxes.
 
void swapBuffers ()
 Call glfwSwapBuffers(m_window).
 
void renderImGui (Universe &universe)
 Render Dear ImGui.
 
void ImGuiControlsMenu (Universe &universe, ImGuiWindowFlags window_flags)
 Render control ImGui menu.
 
void ImGuiInformationMenu (const Universe &universe, ImGuiWindowFlags window_flags)
 Render information ImGui menu.
 
void ImGuiParticleViewerMenu (std::vector< Particle > &particles, ImGuiWindowFlags window_flags)
 Render particles viewer ImGui menu.
 
void ImGuiParticleEditorMenu (std::vector< Particle > &particles, ImGuiWindowFlags window_flags)
 Render particles editor ImGui menu.
 
void toggleSpectatorMode ()
 Toggle spectator mode. The spectator mode will take into account keyboard and mouse inputs for camera movement and show/hide the cursor.
 
void clear ()
 Clears the renderer.
 
bool isRunning ()
 Determines if the renderer is running.
 
const double & getRunTime () const
 Return the run time.
 

Private Attributes

GLFWwindow * m_window
 GLFW window pointer.
 
const Configm_config
 Reference to simulation configuration.
 
std::vector< Boxm_boxes
 Vector of Box.
 
GLUquadric * m_quadric
 GLU Utility for rendering quadratic shapes.
 
Camera m_camera
 
float m_lastX = 0.0f
 Last cursor X position (in pixels).
 
float m_lastY = 0.0f
 Last cursor Y position (in pixels).
 
double m_lastFrameTime = 0.0
 GLFW time of the last frame (in seconds).
 
double m_simulationTimePaused = 0.0
 
double m_runTime = 0.0
 
std::array< bool, 1024 > m_keyStates { {false} }
 States of the keys.
 
bool m_isSpectatorMode = false
 Determines if spectator is enable.
 
double m_scaleFactor
 Scale factor applied for rendering.
 
std::vector< float > m_lastFrameratesBuffer
 vector of last framerates values
 
std::vector< float > m_lastFrameratesIndexes
 vector of last framerates indexes
 

Constructor & Destructor Documentation

◆ Renderer()

Renderer::Renderer ( const Config & config)

Initialize renderer. This method setup the GLFW library for rendering the scene and the Dear ImGui library for rendering the Graphical user interface.

Parameters
[in]configThe simulation configuration
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Renderer()

Renderer::~Renderer ( )

Destroys the renderer.

Member Function Documentation

◆ clear()

void Renderer::clear ( )

Clears the renderer.

Here is the caller graph for this function:

◆ cursorPosCallback()

void Renderer::cursorPosCallback ( double xpos,
double ypos )

Define Callback for cursor position.

Parameters
[in]xposThe cursor x coordinate
[in]yposThe cursor y coordinate

◆ drawBoxes()

void Renderer::drawBoxes ( )

Draws the m_boxes boxes.

Here is the caller graph for this function:

◆ framebufferSizeCallback()

void Renderer::framebufferSizeCallback ( int width,
int height )

Define Callback for window framebuffer size. This method is a callback function given to GLFW via glfwSetFramebufferSizeCallback in initializeGLFW. This method will be called automatically each time the window's framebuffer size change.

Parameters
[in]widthThe width
[in]heightThe height

◆ getRunTime()

const double & Renderer::getRunTime ( ) const
inline

Return the run time.

Returns
The run time
Here is the caller graph for this function:

◆ ImGuiControlsMenu()

void Renderer::ImGuiControlsMenu ( Universe & universe,
ImGuiWindowFlags window_flags )

Render control ImGui menu.

Parameters
universeThe universe
[in]window_flagsThe window flags
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImGuiInformationMenu()

void Renderer::ImGuiInformationMenu ( const Universe & universe,
ImGuiWindowFlags window_flags )

Render information ImGui menu.

Parameters
[in]universeThe universe
[in]window_flagsThe window flags
Here is the caller graph for this function:

◆ ImGuiParticleEditorMenu()

void Renderer::ImGuiParticleEditorMenu ( std::vector< Particle > & particles,
ImGuiWindowFlags window_flags )

Render particles editor ImGui menu.

Parameters
particlesThe particles
[in]window_flagsThe window flags
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImGuiParticleViewerMenu()

void Renderer::ImGuiParticleViewerMenu ( std::vector< Particle > & particles,
ImGuiWindowFlags window_flags )

Render particles viewer ImGui menu.

Parameters
particlesThe particles
window_flagsThe window flags
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initializeGLFW()

void Renderer::initializeGLFW ( )

Initializes the GLFW library. This method is called by the constructor.

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

◆ initializeImGui()

void Renderer::initializeImGui ( )

Initializes the Dear ImGui library. This method is called by the constructor.

Here is the caller graph for this function:

◆ initializeImPlot()

void Renderer::initializeImPlot ( )

Initializes the imPlot library. This method is called by the constructor.

Here is the caller graph for this function:

◆ isRunning()

bool Renderer::isRunning ( )

Determines if the renderer is running.

Returns
True if running, False otherwise.
Here is the caller graph for this function:

◆ keyboardCallback()

void Renderer::keyboardCallback ( int key,
int scancode,
int action,
int mods )

Define Callback for Keyboard inputs.

Parameters
[in]keyThe key
[in]scancodeThe scancode
[in]actionThe action
[in]modsThe mods
Here is the call graph for this function:

◆ render()

void Renderer::render ( Universe & universe)

Renders the given universe.

Parameters
[in]universeThe universe
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderImGui()

void Renderer::renderImGui ( Universe & universe)

Render Dear ImGui.

Parameters
universeThe universe
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderParticleTrail()

void Renderer::renderParticleTrail ( const Particle & particle)

Render the trail of the given particle.

Parameters
particleThe particle
Here is the call graph for this function:
Here is the caller graph for this function:

◆ swapBuffers()

void Renderer::swapBuffers ( )

Call glfwSwapBuffers(m_window).

Here is the caller graph for this function:

◆ toggleSpectatorMode()

void Renderer::toggleSpectatorMode ( )

Toggle spectator mode. The spectator mode will take into account keyboard and mouse inputs for camera movement and show/hide the cursor.

Here is the caller graph for this function:

Member Data Documentation

◆ m_boxes

std::vector<Box> Renderer::m_boxes
private

Vector of Box.

◆ m_camera

Camera Renderer::m_camera
private

◆ m_config

const Config& Renderer::m_config
private

Reference to simulation configuration.

◆ m_isSpectatorMode

bool Renderer::m_isSpectatorMode = false
private

Determines if spectator is enable.

◆ m_keyStates

std::array<bool, 1024> Renderer::m_keyStates { {false} }
private

States of the keys.

◆ m_lastFrameratesBuffer

std::vector<float> Renderer::m_lastFrameratesBuffer
private

vector of last framerates values

◆ m_lastFrameratesIndexes

std::vector<float> Renderer::m_lastFrameratesIndexes
private

vector of last framerates indexes

◆ m_lastFrameTime

double Renderer::m_lastFrameTime = 0.0
private

GLFW time of the last frame (in seconds).

◆ m_lastX

float Renderer::m_lastX = 0.0f
private

Last cursor X position (in pixels).

◆ m_lastY

float Renderer::m_lastY = 0.0f
private

Last cursor Y position (in pixels).

◆ m_quadric

GLUquadric* Renderer::m_quadric
private

GLU Utility for rendering quadratic shapes.

◆ m_runTime

double Renderer::m_runTime = 0.0
private

◆ m_scaleFactor

double Renderer::m_scaleFactor
private

Scale factor applied for rendering.

◆ m_simulationTimePaused

double Renderer::m_simulationTimePaused = 0.0
private

◆ m_window

GLFWwindow* Renderer::m_window
private

GLFW window pointer.