sgltk 0.6
Simple OpenGL Tool Kit
Loading...
Searching...
No Matches
sgltk::Particles Class Reference

The implementation of a particle system using the mesh class. More...

#include <particle.h>

Public Member Functions

void resize (unsigned int number)
 Sets the number of the particles in the system.
void setup_shader (sgltk::Shader *shader)
 Specifies the shader to use to render the particles.
void setup_camera (sgltk::Camera *camera)
 Sets up the view and projection matrices that will be used to render the particles.
void setup_camera (glm::mat4 *view_matrix, glm::mat4 *projection_matrix)
 Sets up the view and projection matrices that will be used to render the particles.
void attach_texture (const std::string &name, const sgltk::Texture &texture)
 Attaches a texture to the particles.
bool add_particle (glm::vec3 position, glm::vec3 velocity, float lifetime)
 Adds a new particle to the system if the particle buffer has an empty space.
bool add_particle_immediately (glm::vec3 position, glm::vec3 velocity, float lifetime)
 Adds a new particle to the system if the particle buffer has an empty space and immediately updates the buffer.
void update_all ()
 Updates the particle buffers.
void draw ()
 Draws the particles.

Detailed Description

The implementation of a particle system using the mesh class.

Definition at line 16 of file particle.h.

Constructor & Destructor Documentation

◆ Particles()

Particles::Particles ( )

Definition at line 5 of file particle.cpp.

◆ ~Particles()

Particles::~Particles ( )

Definition at line 9 of file particle.cpp.

Member Function Documentation

◆ add_particle()

bool Particles::add_particle ( glm::vec3 position,
glm::vec3 velocity,
float lifetime )

Adds a new particle to the system if the particle buffer has an empty space.

Parameters
positionThe position of the new particle
velocityThe velocity vector of the new particle
lifetimeThe lifetime of the particle in seconds
Returns
Returns true if the particle was successfully added to the buffer, false otherwise

Definition at line 50 of file particle.cpp.

◆ add_particle_immediately()

bool Particles::add_particle_immediately ( glm::vec3 position,
glm::vec3 velocity,
float lifetime )

Adds a new particle to the system if the particle buffer has an empty space and immediately updates the buffer.

Parameters
positionThe position of the new particle
velocityThe velocity vector of the new particle
lifetimeThe lifetime of the particle in seconds
Returns
Returns true if the particle was successfully added to the buffer, false otherwise

Definition at line 66 of file particle.cpp.

◆ attach_texture()

void Particles::attach_texture ( const std::string & name,
const sgltk::Texture & texture )

Attaches a texture to the particles.

Definition at line 44 of file particle.cpp.

◆ draw()

void Particles::draw ( )

Draws the particles.

Definition at line 97 of file particle.cpp.

◆ resize()

void Particles::resize ( unsigned int number)

Sets the number of the particles in the system.

Parameters
numberThe new number of particles

Definition at line 12 of file particle.cpp.

◆ setup_camera() [1/2]

void Particles::setup_camera ( glm::mat4 * view_matrix,
glm::mat4 * projection_matrix )

Sets up the view and projection matrices that will be used to render the particles.

Parameters
view_matrixThe view matrix
projection_matrixThe projection matrix

Definition at line 38 of file particle.cpp.

◆ setup_camera() [2/2]

void Particles::setup_camera ( sgltk::Camera * camera)

Sets up the view and projection matrices that will be used to render the particles.

Parameters
cameraThe camera to be used to draw the particles

Definition at line 34 of file particle.cpp.

◆ setup_shader()

void Particles::setup_shader ( sgltk::Shader * shader)

Specifies the shader to use to render the particles.

Parameters
shaderThe shader to be used to render the particles

Definition at line 30 of file particle.cpp.

◆ update_all()

void Particles::update_all ( )

Updates the particle buffers.

Definition at line 88 of file particle.cpp.


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