Files
cuber/cbt/opengl/descriptor.cpp
T
portersky 90d013695d feat: add OpenGL abstraction layer with RAII resources
- 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
2026-05-05 21:58:34 +02:00

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();
}
}