90d013695d
- Replace window class with cbt::opengl::context - Add buffer resource (VBO, EBO, UBO, SSBO) with move semantics - Add texture resource with format/type enums and filtering - Add descriptor_set for Vulkan-style resource binding - All resources use RAII with proper cleanup
42 lines
905 B
C++
42 lines
905 B
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
#include "glad/glad.h"
|
|
|
|
namespace cbt::opengl {
|
|
|
|
enum class buffer_type {
|
|
vertex = GL_ARRAY_BUFFER,
|
|
index = GL_ELEMENT_ARRAY_BUFFER,
|
|
uniform = GL_UNIFORM_BUFFER,
|
|
storage = GL_SHADER_STORAGE_BUFFER,
|
|
};
|
|
|
|
class buffer {
|
|
GLuint m_id = 0;
|
|
buffer_type m_type = buffer_type::vertex;
|
|
|
|
public:
|
|
buffer();
|
|
explicit buffer(buffer_type type);
|
|
~buffer();
|
|
|
|
buffer(const buffer&) = delete;
|
|
buffer& operator=(const buffer&) = delete;
|
|
|
|
buffer(buffer&& other) noexcept;
|
|
buffer& operator=(buffer&& other) noexcept;
|
|
|
|
auto bind() const -> void;
|
|
auto unbind() const -> void;
|
|
auto upload(const void* data, size_t size) -> void;
|
|
auto upload(std::vector<uint8_t> data) -> void;
|
|
auto upload_dynamic(const void* data, size_t size) -> void;
|
|
auto id() const -> GLuint;
|
|
auto valid() const -> bool;
|
|
};
|
|
|
|
}
|