#pragma once #include #include #include "glclasses.hpp" namespace endofthejedi { class ParticleBatch { public: ParticleBatch(size_t numParticles, float particleRadius, float maxAge); // deallocate opengl stuff on destroy ~ParticleBatch(); size_t numParticles() const { return m_numParticles; } void setParticle(size_t index, const glm::vec2 &p, const glm::vec2 &v); void bind(); void upload(); void render(); Shader *shader() { return &m_shader; } private: size_t dataSizeForIndex(int i); void *dataSourceForIndex(int i); private: size_t m_numParticles; float m_particleRadius; float m_maxAge; GLuint m_data_vbos[5]; std::vector m_data_quad; std::vector m_data_position; std::vector m_data_velocity; std::vector m_data_kind; std::vector m_data_max_age; Shader m_shader; }; }