Example #1
0
// Initialization: load and compile shaders, initialize camera(s), load models.
void init() {
  
  GLuint particleSystemShader;
  Screen *primScreen = Engine::instance()->mainScreen();
  Scene *rootScene = Engine::instance()->rootScene();
  
  particleSystemShader = Angel::InitShader( "shaders/vParticle2.glsl",
                                            "shaders/fParticle2.glsl",
                                            "shaders/gParticle.glsl",//"shaders/gParticle.glsl",
      GL_TRIANGLES, GL_TRIANGLE_STRIP, 12 );
  
  rootScene->shader( particleSystemShader );
  primScreen->_camList.shader( particleSystemShader );
  
  {
    ParticleSystem *particleSystem = new ParticleSystem( numberOfParticles, 
							 "emitter", 
							 particleSystemShader );

    particleSystem->setLifespan(8.0, 16.0);
    //particleSystem->setVectorField( ParticleFieldFunctions::userSupplied ) ;
    particleSystem->setVectorField( ParticleFieldFunctions::flame );
    particleSystem->setColorFunc( ColorFunctions::flame ) ;
    particleSystem->setEmitterRadius( 0.04 ) ;
    particleSystem->setEmitterShape(PS_HEMI_D);
    particleSystem->drawMode( GL_TRIANGLES ) ; // NEED THIS IF WE USE A GEOMETRY SHADER!
    //particleSystem->setSlaughterHeight(0.2455);
    //particleSystem->_trans._displacement.set(0.0, 0.25, 0.0);
    //particleSystem->_trans._offset.set( 0.0, 0.2, 0.0 );
    particleSystem->propagateOLD();
    //particleSystem->fillSystemWithParticles();
    rootScene->insertObject( particleSystem );
    // PARTICLE SYSTEMS buffer() THEMSELVES
  }
  
  glClearColor( 0.0, 0.0, 0.0, 1.0 );
  // if not using geo shader, we need this to render visible points
  // glPointSize( 1.1 );
}