mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
introduce Bundle
This commit is contained in:
@@ -146,9 +146,29 @@ struct Prop {
|
|||||||
Prop() : vao(), vbo(), ibo() {}
|
Prop() : vao(), vbo(), ibo() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<unsigned N>
|
||||||
|
struct Bundle : public std::vector<Prop<N>> {
|
||||||
|
};
|
||||||
|
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
struct Renderer {
|
struct Renderer {
|
||||||
virtual void draw(const Prop<N> &) const = 0;
|
virtual void bound(const std::function<void()> &action) const = 0;
|
||||||
|
|
||||||
|
virtual void _draw(const Prop<N> &) const = 0;
|
||||||
|
|
||||||
|
void draw(const Prop<N> &prop) const {
|
||||||
|
bound([&]() {
|
||||||
|
_draw(prop);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw(const Bundle<N> &bundle) const {
|
||||||
|
bound([&]() {
|
||||||
|
for (const Prop<N> &prop : bundle) {
|
||||||
|
_draw(prop);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
@@ -196,15 +216,17 @@ struct SliceRenderer : public Renderer<N> {
|
|||||||
|
|
||||||
SliceRenderer(SliceRenderer &&) noexcept = default;
|
SliceRenderer(SliceRenderer &&) noexcept = default;
|
||||||
|
|
||||||
void draw(const Prop<N> &prop) const override {
|
void bound(const std::function<void()> &action) const override {
|
||||||
pipe.bound([&]() {
|
pipe.bound(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _draw(const Prop<N> &prop) const override {
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, prop.vbo);
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, prop.vbo);
|
||||||
// glProgramUniform3fv(solid, 2, 1, &prop.color.front());
|
// glProgramUniform3fv(solid, 2, 1, &prop.color.front());
|
||||||
glProgramUniform3f(solid, 2, 1.f, 1.f, 1.f);
|
glProgramUniform3f(solid, 2, 1.f, 1.f, 1.f);
|
||||||
prop.vao.bound([&]() {
|
prop.vao.bound([&]() {
|
||||||
glDrawArrays(GL_POINTS, 0, prop.ibo.count() * N);
|
glDrawArrays(GL_POINTS, 0, prop.ibo.count() * N);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -268,7 +290,8 @@ void run(const std::string &config_file, GLFWwindow *window) {
|
|||||||
|
|
||||||
state.dimension = scene["dimension"].as<int>();
|
state.dimension = scene["dimension"].as<int>();
|
||||||
|
|
||||||
auto slices = std::vector<Slice<4>>();
|
auto slices = Bundle<4>();
|
||||||
|
// auto slices = std::vector<Slice<4>>();
|
||||||
// auto wires = std::vector<Wire>();
|
// auto wires = std::vector<Wire>();
|
||||||
|
|
||||||
for (const auto &group_info : scene["groups"]) {
|
for (const auto &group_info : scene["groups"]) {
|
||||||
@@ -370,9 +393,7 @@ void run(const std::string &config_file, GLFWwindow *window) {
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
for (const auto &slice : slices) {
|
sRen.draw(slices);
|
||||||
sRen.draw(slice);
|
|
||||||
}
|
|
||||||
|
|
||||||
glfwSwapInterval(2);
|
glfwSwapInterval(2);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
|||||||
Reference in New Issue
Block a user