| 92 | } |
| 93 | |
| 94 | void BasicParticleApp::draw() |
| 95 | { |
| 96 | // Clear the window. |
| 97 | gl::clear( Color::gray( 0.1f ) ); |
| 98 | |
| 99 | // Enable additive blending. |
| 100 | gl::ScopedBlendAdditive blend; |
| 101 | |
| 102 | // Draw all the particles as lines from mPosition to mLastPosition. |
| 103 | // We use the convenience methods begin(), color(), vertex() and end() for simplicity, |
| 104 | // see the ParticleSphere* samples for a faster method. |
| 105 | gl::begin( GL_LINES ); |
| 106 | for( auto &particle : mParticles ) { |
| 107 | // Color according to velocity. |
| 108 | gl::color( 0.5f + particle.mVelocity.x / ( mSpeed * 2 ), 0.5f + particle.mVelocity.y / ( mSpeed * 2 ), 0.5f + particle.mZ * 0.5f ); |
| 109 | gl::vertex( particle.mLastPosition ); |
| 110 | gl::vertex( particle.mPosition ); |
| 111 | } |
| 112 | gl::end(); |
| 113 | } |
| 114 | |
| 115 | void BasicParticleApp::keyDown( KeyEvent event ) |
| 116 | { |