Particle​ Simulation Documentation
Loading...
Searching...
No Matches
renderer.h
Go to the documentation of this file.
1#ifndef RENDERER_H
2#define RENDERER_H
3
4#include <vector>
5#include <glm/glm.hpp>
6
7#include "universe.h"
8#include "camera.h"
9#include "imgui_impl_glfw.h"
10#include "imgui_impl_opengl3.h"
11#include "implot.h"
12
13class Renderer {
14public:
15
23 Renderer(const Config& config);
24
28 ~Renderer();
29
34 void initializeGLFW();
35
46 void framebufferSizeCallback(int width, int height);
47
54 void cursorPosCallback(double xpos, double ypos);
55
64 void keyboardCallback(int key, int scancode, int action, int mods);
65
70 void initializeImGui();
71
76 void initializeImPlot();
77
83 void render(Universe& universe);
84
90 void renderParticleTrail(const Particle& particle);
91
95 void drawBoxes();
96
100 void swapBuffers();
101
107 void renderImGui(Universe& universe);
108
115 void ImGuiControlsMenu(Universe& universe, ImGuiWindowFlags window_flags);
116
123 void ImGuiInformationMenu(const Universe& universe, ImGuiWindowFlags window_flags);
124
131 void ImGuiParticleViewerMenu(std::vector<Particle>& particles, ImGuiWindowFlags window_flags);
132
139 void ImGuiParticleEditorMenu(std::vector<Particle>& particles, ImGuiWindowFlags window_flags);
140
146 void toggleSpectatorMode();
147
151 void clear();
152
158 bool isRunning();
159
165 const double& getRunTime() const { return m_runTime; }
166
167
168private:
169 GLFWwindow* m_window;
171 std::vector<Box> m_boxes;
172 GLUquadric* m_quadric;
174
175 float m_lastX = 0.0f;
176 float m_lastY = 0.0f;
177
178 double m_lastFrameTime = 0.0;
180 double m_runTime = 0.0;
181
182 std::array<bool, 1024> m_keyStates{ {false} };
183
184 bool m_isSpectatorMode = false;
185
187
188 std::vector<float> m_lastFrameratesBuffer;
189 std::vector<float> m_lastFrameratesIndexes;
190};
191
192#endif // RENDERER_H
Definition camera.h:10
Definition particle.h:9
float m_lastX
Last cursor X position (in pixels).
Definition renderer.h:175
std::vector< Box > m_boxes
Vector of Box.
Definition renderer.h:171
void drawBoxes()
Draws the m_boxes boxes.
Definition renderer.cpp:209
void ImGuiParticleViewerMenu(std::vector< Particle > &particles, ImGuiWindowFlags window_flags)
Render particles viewer ImGui menu.
Definition renderer.cpp:415
double m_runTime
Definition renderer.h:180
Camera m_camera
Definition renderer.h:173
GLUquadric * m_quadric
GLU Utility for rendering quadratic shapes.
Definition renderer.h:172
void initializeGLFW()
Initializes the GLFW library. This method is called by the constructor.
Definition renderer.cpp:28
std::vector< float > m_lastFrameratesBuffer
vector of last framerates values
Definition renderer.h:188
Renderer(const Config &config)
Initialize renderer. This method setup the GLFW library for rendering the scene and the Dear ImGui li...
Definition renderer.cpp:3
double m_scaleFactor
Scale factor applied for rendering.
Definition renderer.h:186
void keyboardCallback(int key, int scancode, int action, int mods)
Define Callback for Keyboard inputs.
Definition renderer.cpp:108
float m_lastY
Last cursor Y position (in pixels).
Definition renderer.h:176
double m_lastFrameTime
GLFW time of the last frame (in seconds).
Definition renderer.h:178
void ImGuiInformationMenu(const Universe &universe, ImGuiWindowFlags window_flags)
Render information ImGui menu.
Definition renderer.cpp:375
void ImGuiControlsMenu(Universe &universe, ImGuiWindowFlags window_flags)
Render control ImGui menu.
Definition renderer.cpp:276
void ImGuiParticleEditorMenu(std::vector< Particle > &particles, ImGuiWindowFlags window_flags)
Render particles editor ImGui menu.
Definition renderer.cpp:430
double m_simulationTimePaused
Definition renderer.h:179
void cursorPosCallback(double xpos, double ypos)
Define Callback for cursor position.
Definition renderer.cpp:97
void renderParticleTrail(const Particle &particle)
Render the trail of the given particle.
Definition renderer.cpp:191
void initializeImPlot()
Initializes the imPlot library. This method is called by the constructor.
Definition renderer.cpp:135
void clear()
Clears the renderer.
Definition renderer.cpp:496
std::array< bool, 1024 > m_keyStates
States of the keys.
Definition renderer.h:182
void renderImGui(Universe &universe)
Render Dear ImGui.
Definition renderer.cpp:249
void initializeImGui()
Initializes the Dear ImGui library. This method is called by the constructor.
Definition renderer.cpp:121
bool isRunning()
Determines if the renderer is running.
Definition renderer.cpp:500
const Config & m_config
Reference to simulation configuration.
Definition renderer.h:170
const double & getRunTime() const
Return the run time.
Definition renderer.h:165
void render(Universe &universe)
Renders the given universe.
Definition renderer.cpp:146
std::vector< float > m_lastFrameratesIndexes
vector of last framerates indexes
Definition renderer.h:189
void toggleSpectatorMode()
Toggle spectator mode. The spectator mode will take into account keyboard and mouse inputs for camera...
Definition renderer.cpp:486
void framebufferSizeCallback(int width, int height)
Define Callback for window framebuffer size. This method is a callback function given to GLFW via glf...
Definition renderer.cpp:85
GLFWwindow * m_window
GLFW window pointer.
Definition renderer.h:169
bool m_isSpectatorMode
Determines if spectator is enable.
Definition renderer.h:184
void swapBuffers()
Call glfwSwapBuffers(m_window).
Definition renderer.cpp:244
~Renderer()
Destroys the renderer.
Definition renderer.cpp:12
Definition universe.h:10
Definition config.h:10