launchCUDAKernel(); // calls the kernel. This call returns immediately.
// The purpose of the following loop is to continuously render the OpenGL scene,
// and update some OpenGL buffers with the contents of a CUDA buffer
// *as soon as* the CUDA buffer has been filled by the CUDA program/kernel
while (true)
{
renderOpenGLScene(); // issues many draw calls, but does not block until they finish (eg. we do not call to glFinish())
// at this point, here, OpenGL commands / draw calls continue to be executed
if (hasCUDAKernelFinishedItsJob())
{
byte[] bufferContents = readSomeCUDABuffer();
updateOpenGLBufferWith(bufferContents);
launchCUDAKernel();
}
}