Uniform buffer objects (#1127)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
Bart Louwers
parent
bbb8bf3c1e
commit
d8ea91de98
49
include/mbgl/gl/uniform_buffer_gl.hpp
Normal file
49
include/mbgl/gl/uniform_buffer_gl.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/uniform_buffer.hpp>
|
||||
#include <mbgl/gl/types.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gl {
|
||||
|
||||
class UniformBufferGL final : public gfx::UniformBuffer {
|
||||
public:
|
||||
UniformBufferGL(const void* data, std::size_t size_);
|
||||
UniformBufferGL(const UniformBufferGL& other)
|
||||
: UniformBuffer(other) {}
|
||||
UniformBufferGL(UniformBufferGL&& other)
|
||||
: UniformBuffer(std::move(other)) {}
|
||||
|
||||
BufferID getID() const { return id; }
|
||||
|
||||
protected:
|
||||
BufferID id = 0;
|
||||
};
|
||||
|
||||
/// Stores a collection of uniform buffers by name
|
||||
class UniformBufferArrayGL final : public gfx::UniformBufferArray {
|
||||
public:
|
||||
UniformBufferArrayGL(int initCapacity = 10)
|
||||
: UniformBufferArray(initCapacity) {}
|
||||
UniformBufferArrayGL(UniformBufferArrayGL&& other)
|
||||
: UniformBufferArray(std::move(other)) {}
|
||||
UniformBufferArrayGL(const UniformBufferArrayGL&) = delete;
|
||||
|
||||
UniformBufferArrayGL& operator=(UniformBufferArrayGL&& other) {
|
||||
UniformBufferArray::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
UniformBufferArrayGL& operator=(const UniformBufferArrayGL& other) {
|
||||
UniformBufferArray::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<gfx::UniformBuffer> copy(const gfx::UniformBuffer& uniformBuffers) override {
|
||||
return std::unique_ptr<gfx::UniformBuffer>(
|
||||
new UniformBufferGL(static_cast<const UniformBufferGL&>(uniformBuffers)));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user