feat(VAO): add VAO config

This commit is contained in:
2025-11-15 20:01:08 +01:00
parent d257c2b827
commit 8bd3080a84
2 changed files with 63 additions and 0 deletions

40
src/VAO.cpp Executable file
View File

@@ -0,0 +1,40 @@
#include "VAO.hpp"
VAO::VAO()
{
glGenVertexArrays(1, &id);
}
VAO::~VAO()
{
glDeleteVertexArrays(1, &id);
}
void VAO::bind()
{
glBindVertexArray(id);
}
void VAO::unbind()
{
glBindVertexArray(0);
}
void VAO::setAttributePointer(GLuint index, GLuint size, GLenum type, GLsizei stride, const void* offset)
{
bind();
glEnableVertexAttribArray(index);
glVertexAttribPointer(index, size, type, GL_FALSE, stride, offset);
}
void VAO::drawElement(GLenum mode, GLsizei count, GLenum type, const void* indices)
{
bind();
glDrawElements(mode, count, type, indices);
}
void VAO::drawArray(GLenum mode, GLint first, GLsizei count)
{
bind();
glDrawArrays(mode, first, count);
}