mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 07:34:16 +00:00
feat(VAO): add VAO config
This commit is contained in:
40
src/VAO.cpp
Executable file
40
src/VAO.cpp
Executable 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);
|
||||
}
|
||||
Reference in New Issue
Block a user