| 156 | } |
| 157 | |
| 158 | void ParticleSphereGPUApp::update() |
| 159 | { |
| 160 | // Update particles on the GPU |
| 161 | gl::ScopedGlslProg prog( mUpdateProg ); |
| 162 | gl::ScopedState rasterizer( GL_RASTERIZER_DISCARD, true ); // turn off fragment stage |
| 163 | mUpdateProg->uniform( "uMouseForce", mMouseForce ); |
| 164 | mUpdateProg->uniform( "uMousePos", mMousePos ); |
| 165 | |
| 166 | // Bind the source data (Attributes refer to specific buffers). |
| 167 | gl::ScopedVao source( mAttributes[mSourceIndex] ); |
| 168 | // Bind destination as buffer base. |
| 169 | gl::bindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER, 0, mParticleBuffer[mDestinationIndex] ); |
| 170 | gl::beginTransformFeedback( GL_POINTS ); |
| 171 | |
| 172 | // Draw source into destination, performing our vertex transformations. |
| 173 | gl::drawArrays( GL_POINTS, 0, NUM_PARTICLES ); |
| 174 | |
| 175 | gl::endTransformFeedback(); |
| 176 | |
| 177 | // Swap source and destination for next loop |
| 178 | std::swap( mSourceIndex, mDestinationIndex ); |
| 179 | |
| 180 | // Update mouse force. |
| 181 | if( mMouseDown ) { |
| 182 | mMouseForce = 150.0f; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | void ParticleSphereGPUApp::draw() |
| 187 | { |
nothing calls this directly
no test coverage detected