vao pointer helper

This commit is contained in:
2020-03-10 13:49:38 -04:00
parent 54ea5dbd53
commit b504e5b7c3
2 changed files with 43 additions and 18 deletions

View File

@@ -318,5 +318,38 @@ namespace cgl {
action();
glBindVertexArray(0);
}
template<class T>
void pointer(
GLuint index,
const buffer<T> &buf,
unsigned size,
GLenum type,
bool normalized = false,
unsigned stride = 0
) const {
bound([&]() {
glEnableVertexAttribArray(index);
buf.bound(GL_ARRAY_BUFFER, [&]() {
glVertexAttribPointer(index, size, type, normalized, stride, nullptr);
});
});
}
template<class T>
void ipointer(
GLuint index,
const buffer<T> &buf,
unsigned size,
GLenum type,
unsigned stride = 0
) const {
bound([&]() {
glEnableVertexAttribArray(index);
buf.bound(GL_ARRAY_BUFFER, [&]() {
glVertexAttribIPointer(index, size, type, stride, nullptr);
});
});
}
};
}