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
33 lines
726 B
C++
33 lines
726 B
C++
#include "cbt/opengl/descriptor.hpp"
|
|
|
|
#include "glad/glad.h"
|
|
|
|
namespace cbt::opengl {
|
|
|
|
descriptor_set::descriptor_set() {}
|
|
|
|
auto descriptor_set::add_texture(texture tex, GLuint unit) -> void {
|
|
m_bindings.push_back({unit, std::move(tex), std::nullopt});
|
|
}
|
|
|
|
auto descriptor_set::add_buffer(buffer buf, GLuint unit) -> void {
|
|
m_bindings.push_back({unit, std::nullopt, std::move(buf)});
|
|
}
|
|
|
|
auto descriptor_set::bind_all() -> void {
|
|
for (auto& binding : m_bindings) {
|
|
if (binding.tex) {
|
|
binding.tex->bind(binding.texture_unit);
|
|
}
|
|
if (binding.buf) {
|
|
binding.buf->bind();
|
|
}
|
|
}
|
|
}
|
|
|
|
auto descriptor_set::count() const -> size_t {
|
|
return m_bindings.size();
|
|
}
|
|
|
|
}
|