#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