58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include <glm/vec2.hpp>
|
|
#include <glm/vec3.hpp>
|
|
|
|
#include "glclasses.hpp"
|
|
|
|
namespace endofthejedi {
|
|
class ParticleBatch {
|
|
public:
|
|
ParticleBatch(size_t id, size_t numParticles, float particleRadius, float halfAge);
|
|
|
|
// deallocate opengl stuff on destroy
|
|
~ParticleBatch();
|
|
|
|
size_t numParticles() const { return m_numParticles; }
|
|
|
|
void setParticle(size_t index, const glm::vec3 &p, const glm::vec3 &v);
|
|
|
|
void setCenter(const glm::vec3 ¢er);
|
|
void setMaxVelocity(float maxVelocity);
|
|
|
|
void setup(Shader *shader);
|
|
void bind();
|
|
void upload();
|
|
void render(Shader *shader);
|
|
|
|
void tick(float dt);
|
|
bool done() const;
|
|
|
|
size_t id() const { return m_id; }
|
|
|
|
private:
|
|
size_t dataSizeForIndex(int i);
|
|
void *dataSourceForIndex(int i);
|
|
|
|
private:
|
|
size_t m_id;
|
|
size_t m_numParticles;
|
|
float m_particleRadius;
|
|
const float m_halfAge;
|
|
float m_age;
|
|
float m_maxVelocity;
|
|
glm::vec3 m_center;
|
|
|
|
GLuint m_data_vbos[5];
|
|
|
|
std::vector<float> m_data_quad;
|
|
std::vector<glm::vec3> m_data_position;
|
|
std::vector<glm::vec3> m_data_velocity;
|
|
std::vector<float> m_data_kind;
|
|
std::vector<float> m_data_max_age;
|
|
|
|
GLuint m_attr_locations[5];
|
|
};
|
|
}
|