Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //create an immutable data storage
- glNamedBufferStorage(uboID, capacity, data, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
- //map entire storage forever
- mappedPtr = glMapNamedBufferRange(uboID, 0, capacity, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
- //bind buffer to target(GL_UNIFORM_BUFFER) binding point
- glBindBufferBase(GL_UNIFORM_BUFFER, uboBinding, uboID);
- //bind shader interface block to target binding point
- glUniformBlockBinding(shaderProgramID, blockIndex, uboBinding);
- //copy data to mapped pointer at stream offset
- memcpy(mappedPtr + uploadOffset, &uploadData[0], uploadSize);
- //This is the important part: tell the shader which range of the buffer to use
- glBindBufferRange(GL_UNIFORM_BUFFER, uboBinding, uboID, uploadOffset, uploadSize);
- //increment offset
- uploadOffset += uploadSize;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement