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
This commit is contained in:
2026-05-05 22:05:40 +02:00
parent 90d013695d
commit df08210f77
6 changed files with 279 additions and 5 deletions
+47
View File
@@ -0,0 +1,47 @@
#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;
}
}