Files
fan/src/uniformbuffer.hpp

43 lines
985 B
C++

#ifndef FAN_UNIFORMBUFFER_HPP_
#define FAN_UNIFORMBUFFER_HPP_
#include <cstddef>
#include <glad/gl.h>
#include "utils.hpp"
namespace Fan
{
class UniformBuffer
{
public:
static Rc<UniformBuffer> create(size_t size, GLuint binding_point);
UniformBuffer(GLuint id, size_t size, GLuint binding_point)
: m_id(id)
, m_size(size)
, m_binding_point(binding_point) {}
~UniformBuffer();
UniformBuffer(const UniformBuffer&) = delete;
UniformBuffer& operator=(const UniformBuffer&) = delete;
UniformBuffer(UniformBuffer&& other) noexcept;
UniformBuffer& operator=(UniformBuffer&& other) noexcept;
GLuint get_id() const;
size_t get_size() const;
GLuint get_binding_point() const;
// Upload data to the GPU buffer
void update(const void* data, size_t size, size_t offset = 0) const;
private:
GLuint m_id{};
size_t m_size{};
GLuint m_binding_point{};
};
} // namespace Fan
#endif // FAN_UNIFORMBUFFER_HPP_