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

Method update

samples/_opengl/ClothSimulation/src/ClothSimulationApp.cpp:196–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196void ClothSimulationApp::update()
197{
198 updateParams();
199
200 if( ! mUpdate ) return;
201
202 gl::ScopedGlslProg scopeGlsl( mUpdateGlsl );
203 gl::ScopedState scopeState( GL_RASTERIZER_DISCARD, true );
204
205 for( auto i = mIterationsPerFrame; i != 0; --i ) {
206 // Bind the vao that has the original vbo attached,
207 // these buffers will be used to read from.
208 gl::ScopedVao scopedVao( mVaos[mIterationIndex & 1] );
209 // Bind the BufferTexture, which contains the positions
210 // of the first vbo. We'll cycle through the neighbors
211 // using the connection buffer so that we can derive our
212 // next position and velocity to write to Transform Feedback
213 gl::ScopedTextureBind scopeTex( mPositionBufTexs[mIterationIndex & 1]->getTarget(), mPositionBufTexs[mIterationIndex & 1]->getId() );
214
215 // We iterate our index so that we'll be using the
216 // opposing buffers to capture the data
217 mIterationIndex++;
218
219 // Now bind our opposing buffers to the correct index
220 // so that we can capture the values coming from the shader
221 gl::bindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER, POSITION_INDEX, mPositions[mIterationIndex & 1] );
222 gl::bindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER, VELOCITY_INDEX, mVelocities[mIterationIndex & 1] );
223
224 // Begin Transform feedback with the correct primitive,
225 // In this case, we want GL_POINTS, because each vertex
226 // exists by itself
227 gl::beginTransformFeedback( GL_POINTS );
228 // Now we issue our draw command which puts all of the
229 // setup in motion and processes all the vertices
230 gl::drawArrays( GL_POINTS, 0, POINTS_TOTAL );
231 // After that we issue an endTransformFeedback command
232 // to tell OpenGL that we're finished capturing vertices
233 gl::endTransformFeedback();
234 }
235}
236
237void ClothSimulationApp::draw()
238{

Callers

nothing calls this directly

Calls 5

bindBufferBaseFunction · 0.85
beginTransformFeedbackFunction · 0.85
drawArraysFunction · 0.85
endTransformFeedbackFunction · 0.85
getTargetMethod · 0.80

Tested by

no test coverage detected