6#include <brenta/renderer/opengl/vao.hpp>
7#include <brenta/logger.hpp>
19 glGenVertexArrays(1, &this->
id);
20 EVENT(Logger::Event::Lifetime,
"Vao: initialized {}", this->
id);
26 if (this->get_id() == 0)
return;
28 glDeleteVertexArrays(1, &this->
id);
30 EVENT(Logger::Event::Lifetime,
"Vao: destroyed {}", this->
id);
37 if (this->get_id() == 0)
39 ERROR(
"Vao::bind: not initialized");
42 glBindVertexArray(this->get_id());
46void Vao::unbind()
const
52unsigned int Vao::get_id()
const
59void Vao::link_buffer(
const Buffer &vbo,
60 unsigned int layout_index,
68 GLint old_vao, old_vbo;
69 glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &old_vao);
70 glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &old_vbo);
74 glVertexAttribPointer(layout_index, components, type,
75 normalized, stride, offset);
76 glEnableVertexAttribArray(layout_index);
79 glBindBuffer(GL_ARRAY_BUFFER, old_vbo);
80 glBindVertexArray(old_vao);