TAMSVIZ
Visualization and annotation tool for ROS
uniformbuffer.cpp
1 // TAMSVIZ
2 // (c) 2020 Philipp Ruppel
3 
4 #include "uniformbuffer.h"
5 
6 void UniformBufferBase::destroy() {
7  if (_buffer) {
8  GLuint buffer = _buffer;
9  cleanup([buffer]() { V_GL(glDeleteBuffers(1, &buffer)); });
10  _buffer = 0;
11  }
12 }
13 
14 void UniformBufferBase::update(const void *data, size_t size) {
15  if (!_buffer) {
16  V_GL(glGenBuffers(1, &_buffer));
17  }
18  V_GL(glBindBuffer(GL_UNIFORM_BUFFER, _buffer));
19  V_GL(glBufferData(GL_UNIFORM_BUFFER, size, data, GL_DYNAMIC_DRAW));
20 }
21 
22 void UniformBufferBase::bind(size_t binding_point) {
23  V_GL(glBindBufferBase(GL_UNIFORM_BUFFER, binding_point, _buffer));
24 }
25 
26 void UniformBufferBase::bind(size_t binding_point, size_t offset, size_t size) {
27  V_GL(glBindBufferRange(GL_UNIFORM_BUFFER, binding_point, _buffer, offset,
28  size));
29 }