mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
ENH: Upload to buffer from iterator
This commit is contained in:
@@ -53,8 +53,12 @@ namespace cgl {
|
||||
glNamedBufferData(id, sizeof(T), &data, usage);
|
||||
}
|
||||
|
||||
void put(const std::vector<T> &data, GLenum usage = GL_STATIC_DRAW) {
|
||||
glNamedBufferData(id, sizeof(T) * data.size(), &data[0], usage);
|
||||
template<typename It>
|
||||
void put(It begin, It end, GLenum usage = GL_STATIC_DRAW) {
|
||||
glNamedBufferData(id, sizeof(T) * (end - begin), nullptr, usage);
|
||||
void* ptr = glMapNamedBuffer(id, GL_WRITE_ONLY);
|
||||
std::copy(begin, end, (T*) ptr);
|
||||
glUnmapNamedBuffer(id);
|
||||
}
|
||||
|
||||
void bound(GLenum target, const std::function<void()> &action) const {
|
||||
|
||||
@@ -153,8 +153,10 @@ struct SliceProp : public Prop<N> {
|
||||
) {
|
||||
SliceProp<N> res(color);
|
||||
|
||||
res.vbo.put(points(g, coords));
|
||||
res.ibo.put(merge<N>(hull<N>(g, all_sg_gens, exclude)));
|
||||
auto pts = points(g, coords);
|
||||
res.vbo.put(pts.begin(), pts.end());
|
||||
auto inds = merge<N>(hull<N>(g, all_sg_gens, exclude));
|
||||
res.ibo.put(inds.begin(), inds.end());
|
||||
res.vao.ipointer(0, res.ibo, 4, GL_UNSIGNED_INT);
|
||||
|
||||
return res;
|
||||
@@ -244,8 +246,10 @@ struct WireframeProp : public Prop<2> {
|
||||
) {
|
||||
WireframeProp res(color);
|
||||
|
||||
res.vbo.put(points(g, coords));
|
||||
res.ibo.put(merge<2>(hull<2>(g, all_sg_gens, exclude)));
|
||||
auto pts = points(g, coords);
|
||||
res.vbo.put(pts.begin(), pts.end());
|
||||
auto inds = merge<2>(hull<2>(g, all_sg_gens, exclude));
|
||||
res.ibo.put(inds.begin(), inds.end());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user