Skip to content

Instantly share code, notes, and snippets.

@ratchetfreak
Created February 24, 2016 10:41
Show Gist options
  • Save ratchetfreak/3b1e5c1fdbfbc11223a3 to your computer and use it in GitHub Desktop.
Save ratchetfreak/3b1e5c1fdbfbc11223a3 to your computer and use it in GitHub Desktop.
syncing mapped buffers using flush
//map buffer with GL_MAP_FLUSH_EXPLICIT_BIT
waitBuffer(gl4, rbWriteIndex);
perMeshPointer.position(rbAlignment * rbWriteIndex);
perMeshPointer.asFloatBuffer().put(perMesh[i].toFa());
perMeshPointer.rewind();
gl4.glFlushMappedBufferRange(GL_UNIFORM_BUFFER, rbAlignment * rbWriteIndex, rbAlignment);
gl4.glBindBufferRange(GL_UNIFORM_BUFFER,
Semantic.Uniform.PER_MESH,
bufferName.get(Buffer.PER_MESH),
rbAlignment * rbWriteIndex,
rbAlignment
);
/* do render*/
lockBuffer(gl4, rbWriteIndex);
rbWriteIndex = (rbWriteIndex + 1) % rbMax;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment