Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. //create an immutable data storage
  2. glNamedBufferStorage(uboID, capacity, data, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
  3.  
  4. //map entire storage forever
  5. mappedPtr = glMapNamedBufferRange(uboID, 0, capacity, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
  6.  
  7. //bind buffer to target(GL_UNIFORM_BUFFER) binding point
  8. glBindBufferBase(GL_UNIFORM_BUFFER, uboBinding, uboID);
  9.  
  10. //bind shader interface block to target binding point
  11. glUniformBlockBinding(shaderProgramID, blockIndex, uboBinding);
  12.  
  13. //copy data to mapped pointer at stream offset
  14. memcpy(mappedPtr + uploadOffset, &uploadData[0], uploadSize);
  15.  
  16. //This is the important part: tell the shader which range of the buffer to use
  17. glBindBufferRange(GL_UNIFORM_BUFFER, uboBinding, uboID, uploadOffset, uploadSize);
  18.  
  19. //increment offset
  20. uploadOffset += uploadSize;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement