KlassischeKeplerKriege/game/renderer_polygon_3d/particle_batch.hpp

51 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
#include <vector>
#include <glm/vec2.hpp>
#include "glclasses.hpp"
namespace endofthejedi {
class ParticleBatch {
public:
2016-09-28 22:50:14 +00:00
ParticleBatch(size_t numParticles, float particleRadius, float maxAge);
// deallocate opengl stuff on destroy
~ParticleBatch();
size_t numParticles() const { return m_numParticles; }
2016-09-28 22:50:14 +00:00
void setParticle(size_t index, const glm::vec2 &p, const glm::vec2 &v);
void bind();
void upload();
void render();
2016-09-29 06:28:56 +00:00
void tick(float dt);
bool done() const;
Shader *shader() { return &m_shader; }
private:
size_t dataSizeForIndex(int i);
void *dataSourceForIndex(int i);
private:
size_t m_numParticles;
2016-09-28 22:50:14 +00:00
float m_particleRadius;
2016-09-29 06:28:56 +00:00
const float m_maxAge;
float m_age;
2016-09-28 22:50:14 +00:00
GLuint m_data_vbos[5];
2016-09-28 22:50:14 +00:00
std::vector<float> m_data_quad;
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;
Shader m_shader;
};
}