Skip to content

Instantly share code, notes, and snippets.

@pingpoli
Created August 6, 2020 20:18
Show Gist options
  • Save pingpoli/55c3d93d4662e59455f5cefbc60e8d0c to your computer and use it in GitHub Desktop.
Save pingpoli/55c3d93d4662e59455f5cefbc60e8d0c to your computer and use it in GitHub Desktop.
#pragma once
#include "Z:/cpp/SRC/lgl3/include/lgl3_includes.hpp"
#include "Z:/cpp/SRC/lgl3/include/lglShader.hpp"
/*
emitter
*/
class SimpleEmitter
{
public:
SimpleEmitter();
~SimpleEmitter();
void update( const float dt );
void draw();
private:
struct Particle
{
vec3 position;
float lifetime;
};
std::vector< Particle > particles;
float positions[400];
GLuint vertexBuffer;
GLuint positionBuffer;
};
/*
shader
*/
class SimpleParticleShader : public lglShader
{
public:
SimpleParticleShader();
~SimpleParticleShader();
void setUniformViewMatrix( const mat4& M_v );
void setUniformProjectionMatrix( const mat4& M_p );
void setUniformParticleSize( const float particleSize );
private:
static const std::string VS;
static const std::string FS;
GLuint u_M_v;
GLuint u_M_p;
GLuint u_particleSize;
};
/*
controller
*/
class SimpleController
{
public:
SimpleController();
~SimpleController();
void draw( const float dt , const mat4 M_p , const mat4& M_v );
private:
SimpleParticleShader* shader;
SimpleEmitter* emitter;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment