Files
MapLibreParticleLab/src/mbgl/gl/uniform_block_gl.cpp
mwilsnd 8b2c748341 OpenGL: Monotonic UBO allocator (#1911)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
2023-12-12 12:39:34 -05:00

32 lines
1011 B
C++

#include <mbgl/gl/context.hpp>
#include <mbgl/gl/uniform_block_gl.hpp>
#include <mbgl/gl/uniform_buffer_gl.hpp>
#include <mbgl/gl/defines.hpp>
#include <mbgl/platform/gl_functions.hpp>
#include <cassert>
namespace mbgl {
namespace gl {
using namespace platform;
void UniformBlockGL::bindBuffer(const gfx::UniformBuffer& uniformBuffer) {
assert(size == uniformBuffer.getSize());
GLint binding = index;
const auto& uniformBufferGL = static_cast<const UniformBufferGL&>(uniformBuffer);
MBGL_CHECK_ERROR(glBindBufferRange(GL_UNIFORM_BUFFER,
binding,
uniformBufferGL.getID(),
uniformBufferGL.getManagedBuffer().getBindingOffset(),
uniformBufferGL.getSize()));
}
void UniformBlockGL::unbindBuffer() {
GLint binding = index;
MBGL_CHECK_ERROR(glBindBufferBase(GL_UNIFORM_BUFFER, binding, 0));
}
} // namespace gl
} // namespace mbgl