diff --git a/vis/include/cgl/buffer.hpp b/vis/include/cgl/buffer.hpp index 57b0977..d359630 100644 --- a/vis/include/cgl/buffer.hpp +++ b/vis/include/cgl/buffer.hpp @@ -24,7 +24,7 @@ namespace cgl { put(data, usage); } - Buffer(Buffer &) = delete; + Buffer(const Buffer &) = delete; Buffer(Buffer &&o) noexcept { id = std::exchange(o.id, 0); diff --git a/vis/include/rendering.hpp b/vis/include/rendering.hpp index ab74460..875a268 100644 --- a/vis/include/rendering.hpp +++ b/vis/include/rendering.hpp @@ -5,10 +5,12 @@ #include #include -template +#include + +template struct Prop { cgl::VertexArray vao; - cgl::Buffer vbo; + std::tuple...> vbos; cgl::Buffer> ibo; }; @@ -38,7 +40,7 @@ struct SliceRenderer : public Renderer { void draw(const Prop &prop) const override { pipe.bound([&]() { - glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, prop.vbo); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, std::get<0>(prop.vbos)); //// glProgramUniform3fv(solid, 2, 1, &prop.color.front()); glProgramUniform3f(solid, 2, 1.f, 1.f, 1.f); prop.vao.bound([&]() { @@ -47,145 +49,3 @@ struct SliceRenderer : public Renderer { }); } }; - -//template -//struct Prop { -// cgl::VertexArray vao; -// cgl::Buffer vbo; -// cgl::Buffer> ibo; -// -// Prop() : vao(), vbo(), ibo() {} -//}; -// -//template -//struct Renderer { -// std::vector> props; -// -// virtual void bound(const std::function &action) const = 0; -// -// virtual void _draw(const Prop &) const = 0; -// -// void render() const { -// bound([&]() { -// for (const auto &prop : props) { -// _draw(prop); -// } -// }); -// } -//}; -// -//template -//struct SliceProp : public Prop { -// vec3 color; -// -// SliceProp(vec3 color) : Prop(), color(color) {} -// -// SliceProp(SliceProp &) = delete; -// -// SliceProp(SliceProp &&) noexcept = default; -// -// template -// static SliceProp build( -// const tc::Group &g, -// const C &coords, -// vec3 color, -// T all_sg_gens, -// const std::vector> &exclude -// ) { -// SliceProp res(color); -// -// res.vbo.put(points(g, coords)); -// res.ibo.put(merge(hull(g, all_sg_gens, exclude))); -// res.vao.ipointer(0, res.ibo, 4, GL_UNSIGNED_INT); -// -// return res; -// } -//}; -// -//template -//struct SliceRenderer : public Renderer { -// cgl::pgm::vert defer = cgl::pgm::vert::file( -// "shaders/slice/deferred.vs.glsl"); -// cgl::pgm::geom slice = cgl::pgm::geom::file( -// "shaders/slice/slice.gm.glsl"); -// cgl::pgm::frag solid = cgl::pgm::frag::file( -// "shaders/solid.fs.glsl"); -// -// cgl::pipeline pipe; -// -// SliceRenderer() { -// pipe.stage(defer); -// pipe.stage(slice); -// pipe.stage(solid); -// } -// -// SliceRenderer(SliceRenderer &) = delete; -// -// SliceRenderer(SliceRenderer &&) noexcept = default; -// -// void bound(const std::function &action) const override { -// pipe.bound(action); -// } -// -// void _draw(const Prop &prop) const override { -// glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, prop.vbo); -//// glProgramUniform3fv(solid, 2, 1, &prop.color.front()); -// glProgramUniform3f(solid, 2, 1.f, 1.f, 1.f); -// prop.vao.bound([&]() { -// glDrawArrays(GL_POINTS, 0, prop.ibo.count() * N); -// }); -// } -//}; -// -// -//template -//struct DirectRenderer : public Renderer { -// cgl::pipeline pipe; -// -// DirectRenderer() = default; -// -// DirectRenderer(DirectRenderer &) = delete; -// -// DirectRenderer(DirectRenderer &&) noexcept = default; -// -// void bound(const std::function &action) const override { -// pipe.bound(action); -// } -// -// void _draw(const Prop &prop) const override { -// glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, prop.vbo); -//// glProgramUniform3fv(sh.solid, 2, 1, &wire.color.front()); -// prop.vao.bound([&]() { -// prop.ibo.bound(GL_ELEMENT_ARRAY_BUFFER, [&]() { -// glDrawElements(GL_LINES, prop.ibo.count() * N, GL_UNSIGNED_INT, nullptr); -// }); -// }); -// } -//}; -// -//struct WireframeProp : public Prop<2> { -// vec3 color; -// -// WireframeProp(vec3 color) : Prop<2>(), color(color) {} -// -// WireframeProp(WireframeProp &) = delete; -// -// WireframeProp(WireframeProp &&) noexcept = default; -// -// template -// static WireframeProp build(const tc::Group &g, -// const C &coords, -// bool curve, -// bool ortho, -// vec3 color, -// T all_sg_gens, -// const std::vector> &exclude -// ) { -// WireframeProp res(color); -// -// res.vbo.put(points(g, coords)); -// res.ibo.put(merge<2>(hull<2>(g, all_sg_gens, exclude))); -// -// return res; -// } -//}; diff --git a/vis/src/main.cpp b/vis/src/main.cpp index 8e960b1..17a2788 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -142,7 +142,7 @@ void run(const std::string &config_file, GLFWwindow *window) { glLineWidth(1.5); - prop.vbo.put(points(group, root, time)); + std::get<0>(prop.vbos).put(points(group, root, time)); Matrices mats{};