40ae94788e
- C++ std headers first, then third-party, then local - Apply consistently in cbt/ and scenes/
33 lines
726 B
C++
33 lines
726 B
C++
#include "glad/glad.h"
|
|
|
|
#include "cbt/opengl/descriptor.hpp"
|
|
|
|
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();
|
|
}
|
|
|
|
}
|