Graphics Reference
In-Depth Information
Example 13-1
Inserting a Fence Command and Waiting for Its Result in
Transform Feedback Example
void EmitParticles ( ESContext *esContext, float deltaTime )
{
// Many codes skipped ...
// Emit particles using transform feedback
glBeginTransformFeedback ( GL_POINTS );
glDrawArrays ( GL_POINTS, 0, NUM_PARTICLES );
glEndTransformFeedback ( );
// Create a sync object to ensure transform feedback results
// are completed before the draw that uses them
userData->emitSync =
glFenceSync ( GL_SYNC_GPU_COMMANDS_COMPLETE, 0 );
// Many codes skipped ...
}
void Draw ( ESContext *esContext )
{
UserData *userData = ( UserData* ) esContext->userData;
// Block the GL server until transform feedback results
// are completed
glWaitSync ( userData->emitSync, 0, GL_TIMEOUT_IGNORED );
glDeleteSync ( userData->emitSync );
// Many codes skipped ...
glDrawArrays ( GL_POINTS, 0, NUM_PARTICLES );
}
Summary
In this chapter, you learned about efficient primitives for synchronizing
within the host application and GPU execution in OpenGL ES 3.0. We
discussed how to use the sync objects and fences. In the next chapter,
you will see many advanced rendering examples that tie together all the
concepts you have learned so far throughout the topic.
 
 
 
Search WWH ::




Custom Search