44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include <glm/vec2.hpp>
|
|
|
|
#include "glclasses.hpp"
|
|
|
|
namespace endofthejedi {
|
|
class ParticleBatch {
|
|
public:
|
|
ParticleBatch(size_t numParticles, float particleRadius);
|
|
|
|
// 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, float kind, float maxAge);
|
|
|
|
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;
|
|
GLuint m_data_vbos[4];
|
|
|
|
std::vector<glm::vec2> m_data_position;
|
|
std::vector<glm::vec2> m_data_velocity;
|
|
std::vector<float> m_data_kind;
|
|
std::vector<float> m_data_max_age;
|
|
|
|
float m_particleRadius;
|
|
|
|
Shader m_shader;
|
|
};
|
|
}
|