sgltk 0.6
Simple OpenGL Tool Kit
Loading...
Searching...
No Matches
particle.h
1#ifndef __PARTICLE_H__
2#define __PARTICLE_H__
3
4#include "app.h"
5#include "mesh.h"
6#include "timer.h"
7#include "shader.h"
8#include "camera.h"
9
10namespace sgltk {
11
16class Particles {
17 Mesh mesh;
18 Timer timer;
19 unsigned int pos_buf;
20 unsigned int vel_buf;
21 unsigned int life_buf;
22 unsigned int number;
23
24 std::vector<glm::vec3> position;
25 std::vector<glm::vec3> velocity;
26 std::vector<glm::vec2> lifetime;
27 std::vector<unsigned int> indices;
28public:
29 EXPORT Particles();
30 EXPORT ~Particles();
31
36 EXPORT void resize(unsigned int number);
41 EXPORT void setup_shader(sgltk::Shader *shader);
47 EXPORT void setup_camera(sgltk::Camera *camera);
54 EXPORT void setup_camera(glm::mat4 *view_matrix,
55 glm::mat4 *projection_matrix);
59 EXPORT void attach_texture(const std::string& name,
60 const sgltk::Texture& texture);
69 EXPORT bool add_particle(glm::vec3 position,
70 glm::vec3 velocity,
71 float lifetime);
81 EXPORT bool add_particle_immediately(glm::vec3 position,
82 glm::vec3 velocity,
83 float lifetime);
87 EXPORT void update_all();
91 EXPORT void draw();
92};
93
94}
95
96#endif
Manages cameras.
Definition camera.h:12
Manages meshes.
Definition mesh.h:139
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 t...
Definition particle.cpp:66
void setup_camera(sgltk::Camera *camera)
Sets up the view and projection matrices that will be used to render the particles.
Definition particle.cpp:34
void draw()
Draws the particles.
Definition particle.cpp:97
void setup_shader(sgltk::Shader *shader)
Specifies the shader to use to render the particles.
Definition particle.cpp:30
void attach_texture(const std::string &name, const sgltk::Texture &texture)
Attaches a texture to the particles.
Definition particle.cpp:44
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.
Definition particle.cpp:50
void update_all()
Updates the particle buffers.
Definition particle.cpp:88
void resize(unsigned int number)
Sets the number of the particles in the system.
Definition particle.cpp:12
Manager shaders.
Definition shader.h:12
Manages textures.
Definition texture.h:13
Provides a simple timer.
Definition timer.h:12