Files
cuber/cbt/opengl/vao.cpp
T
portersky df08210f77 feat: render per-vertex color triangle
- Add shader class for vertex/fragment program compilation
- Add vao class for vertex array object management
- Render RGB gradient triangle with interpolated vertex colors
2026-05-05 22:05:40 +02:00

48 lines
728 B
C++

#include "cbt/opengl/vao.hpp"
namespace cbt::opengl {
vao::vao() {
glGenVertexArrays(1, &m_id);
}
vao::~vao() {
if (m_id) {
glDeleteVertexArrays(1, &m_id);
}
}
vao::vao(vao&& other) noexcept
: m_id(other.m_id) {
other.m_id = 0;
}
vao& vao::operator=(vao&& other) noexcept {
if (this != &other) {
if (m_id) {
glDeleteVertexArrays(1, &m_id);
}
m_id = other.m_id;
other.m_id = 0;
}
return *this;
}
auto vao::bind() const -> void {
glBindVertexArray(m_id);
}
auto vao::unbind() const -> void {
glBindVertexArray(0);
}
auto vao::id() const -> GLuint {
return m_id;
}
auto vao::valid() const -> bool {
return m_id != 0;
}
}