MCPcopy Create free account
hub / github.com/cinder/Cinder / update

Method update

samples/_opengl/ParticleSphereGPU/src/ParticleSphereGPUApp.cpp:158–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void 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
186void ParticleSphereGPUApp::draw()
187{

Callers

nothing calls this directly

Calls 6

bindBufferBaseFunction · 0.85
beginTransformFeedbackFunction · 0.85
drawArraysFunction · 0.85
endTransformFeedbackFunction · 0.85
uniformMethod · 0.80
swapFunction · 0.50

Tested by

no test coverage detected