diff options
| author | Thomas Guillermo Albers Raviola <thomas@thomaslabs.org> | 2026-01-16 23:02:32 +0100 |
|---|---|---|
| committer | Thomas Guillermo Albers Raviola <thomas@thomaslabs.org> | 2026-01-16 23:02:32 +0100 |
| commit | 6b8af9cf83851c075c6c9514b1deaa931c2b19a4 (patch) | |
| tree | 428986b49c32e21d3f7a3c2dfa41858ae0153209 /09-september/tomcat/particles/particles.h | |
Initial commit
Diffstat (limited to '09-september/tomcat/particles/particles.h')
| -rw-r--r-- | 09-september/tomcat/particles/particles.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/09-september/tomcat/particles/particles.h b/09-september/tomcat/particles/particles.h new file mode 100644 index 0000000..8404ff4 --- /dev/null +++ b/09-september/tomcat/particles/particles.h @@ -0,0 +1,62 @@ +#ifndef PARTICLES_H +#define PARTICLES_H + +#include "../renderer/renderer_types.h" +#include "../math/vector.h" + +#define MAX_PARTICLES_PER_SYSTEM 10000 +#define MAX_PARTICLES_SYSTEMS 10 + +typedef struct _Particle +{ + Vec3 position; + Vec3 velocity; + + Vec2 tex_offset; /* Used for animating */ + + GLfloat weight; /* How does the gravity affect the particle (In theory it should be a vector)*/ + GLfloat life_length; + GLfloat rotation; + GLfloat scale; + GLfloat distance_to_camera; /* Used for sorting the systems */ + + GLfloat elapsed_time; +} Particle; + +typedef struct _ParticleSystem +{ + Vec3 position; + + GLint emit_rate; + GLfloat speed; + GLfloat weight; + GLfloat life_length; + + bool additive; /* Additive vs alpha blending */ + + Texture *texture; + Particle particles[MAX_PARTICLES_PER_SYSTEM]; + int num_particles; + +} ParticleSystem; + +typedef struct +{ + ParticleSystem *systems[MAX_PARTICLES_SYSTEMS]; + int num_systems; +} ParticleManager; + +extern ParticleManager particles; + +extern void Particles_Init(); + +extern ParticleSystem *Particles_AddSystem(); +extern void Particles_RemoveSystem(ParticleSystem *system); +/* Used for manual emission */ +extern void Particles_EmitParticle(ParticleSystem *system, Particle *p); +/* Removes a particle if it "dies" */ +extern void Particles_Update(const Vec3 *camera_position); +/* We need to delete all dynamically allocated particles that still remains */ +extern void Particles_Shutdown(); + +#endif // PARTICLES_H |
