mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
Introduce cgl::Buffer::put<E> for Eigen matrices and other containers.
Make put(std::vector<T>) more generic by specializing the new put<E> method.
This commit is contained in:
@@ -53,14 +53,20 @@ namespace cgl {
|
||||
glNamedBufferData(id, sizeof(T), &data, usage);
|
||||
}
|
||||
|
||||
void put(const std::vector<T> &data, GLenum usage = GL_STATIC_DRAW) {
|
||||
put(&data[0], data.size(), usage);
|
||||
}
|
||||
|
||||
void put(const T *data, const size_t &size, GLenum usage = GL_STATIC_DRAW) {
|
||||
glNamedBufferData(id, sizeof(T) * size, data, usage);
|
||||
}
|
||||
|
||||
template<class E>
|
||||
void put(const E &data, GLenum usage = GL_STATIC_DRAW) {
|
||||
put(data.data(), data.size(), usage);
|
||||
}
|
||||
|
||||
template<>
|
||||
void put<std::vector<T>>(const std::vector<T> &data, GLenum usage = GL_STATIC_DRAW) {
|
||||
put(data.data, data.size(), usage);
|
||||
}
|
||||
|
||||
void bound(GLenum target, const std::function<void()> &action) const {
|
||||
glBindBuffer(target, id);
|
||||
action();
|
||||
|
||||
Reference in New Issue
Block a user