1#ifndef TATOOINE_RENDERING_INTERACTIVE_ELLIPSE_H
2#define TATOOINE_RENDERING_INTERACTIVE_ELLIPSE_H
14template <
typename Ellipse>
15requires(is_derived_from_hyper_ellipse<Ellipse> &&
16 Ellipse::num_dimensions() == 2)
21 static auto get() ->
auto& {
22 static auto instance = geometry{};
25 explicit geometry(std::size_t
const num_vertices = 32) {
26 vertexbuffer().resize(num_vertices);
30 auto vb_map = vertexbuffer().wmap();
31 auto i = std::size_t{};
32 for (
auto const t : ts) {
36 indexbuffer().resize(num_vertices);
38 auto data = indexbuffer().wmap();
39 for (std::size_t i = 0; i < num_vertices; ++i) {
58 ImGui::Text(
"Ellipse");
59 ImGui::DragInt(
"Line width", &line_width, 1, 1, 20);
60 ImGui::ColorEdit4(
"Color", color.
data());
65 auto constexpr O = GLfloat(0);
66 auto constexpr I = GLfloat(1);
67 static auto constexpr ell_is_float = is_same<GLfloat, real_type>;
68 if constexpr (ell_is_float) {
70 {S(1, 0), S(1, 1), O, center(1)},
75 {GLfloat(S(0, 0)), GLfloat(S(0, 1)), O, GLfloat(center(0))},
76 {GLfloat(S(1, 0)), GLfloat(S(1, 1)), O, GLfloat(center(1))},
84 using cam_real_type =
typename std::decay_t<
decltype(cam)>
::real_type;
85 static auto constexpr ell_is_float = is_same<GLfloat, real_type>;
86 static auto constexpr cam_is_float = is_same<GLfloat, cam_real_type>;
89 if constexpr (cam_is_float) {
90 return cam.view_matrix();
96 construct_model_matrix(ell.S(), ell.center()));
107template <range EllipseRange>
109 std::ranges::range_value_t<EllipseRange>> &&
110 std::ranges::range_value_t<EllipseRange>::num_dimensions() == 2)
115 typename ellipse_type::real_type;
126 shader::get().set_projection_matrix(P);
130 ImGui::Text(
"Ellipse");
131 ImGui::DragInt(
"Line width", &line_width, 1, 1, 20);
132 ImGui::ColorEdit4(
"Color", color.
data());
137 auto constexpr O = GLfloat(0);
138 auto constexpr I = GLfloat(1);
139 static auto constexpr ell_is_float = is_same<GLfloat, real_type>;
140 if constexpr (ell_is_float) {
142 {S(1, 0), S(1, 1), O, center(1)},
147 {GLfloat(S(0, 0)), GLfloat(S(0, 1)), O, GLfloat(center(0))},
148 {GLfloat(S(1, 0)), GLfloat(S(1, 1)), O, GLfloat(center(1))},
155 auto&
shader = shader::get();
157 using cam_real_type =
typename std::decay_t<
decltype(cam)>
::real_type;
158 static auto constexpr cam_is_float = is_same<GLfloat, cam_real_type>;
161 shader.set_color(color(0), color(1), color(2), color(3));
163 if constexpr (cam_is_float) {
164 return cam.view_matrix();
169 for (
auto const& ell : ellipses) {
170 shader.set_model_view_matrix(
171 V * construct_model_matrix(ell.S(), ell.center()));
172 geometry::get().draw_line_loop();
Definition: indexeddata.h:13
constexpr auto data() -> ValueType *
Definition: static_multidim_array.h:260
DLL_API auto line_width(GLfloat width) -> void
Definition: interactive.h:15
typename get_impl< Container, I >::type get
Definition: get.h:11
static auto constexpr is_derived_from_hyper_ellipse
Definition: hyper_ellipse.h:306
Definition: linspace.h:26
constexpr auto pop_back()
Definition: linspace.h:107
std::ranges::range_value_t< EllipseRange > ellipse_type
Definition: ellipse.h:113
static auto set_projection_matrix(Mat4< GLfloat > const &P)
Definition: ellipse.h:125
typename renderer< ellipse_type >::geometry geometry
Definition: ellipse.h:117
static auto construct_model_matrix(Mat2< real_type > const &S, Vec2< real_type > const ¢er)
Definition: ellipse.h:135
renderer(renderable_type const &)
Definition: ellipse.h:123
EllipseRange renderable_type
Definition: ellipse.h:112
auto render(auto const &ellipses, camera auto const &cam)
Definition: ellipse.h:154
auto properties(renderable_type const &)
Definition: ellipse.h:129
typename renderer< ellipse_type >::shader shader
Definition: ellipse.h:118
typename ellipse_type::real_type real_type
Definition: ellipse.h:115
geometry(std::size_t const num_vertices=32)
Definition: ellipse.h:25
static auto get() -> auto &
Definition: ellipse.h:21
auto update(auto const, auto &ell, camera auto const &cam)
Definition: ellipse.h:82
typename Ellipse::real_type real_type
Definition: ellipse.h:19
auto render()
Definition: ellipse.h:100
auto properties(renderable_type const &)
Definition: ellipse.h:57
Ellipse renderable_type
Definition: ellipse.h:18
renderer(renderable_type const &)
Definition: ellipse.h:51
static auto set_projection_matrix(Mat4< GLfloat > const &P)
Definition: ellipse.h:53
static auto construct_model_matrix(Mat2< real_type > const &S, Vec2< real_type > const ¢er)
Definition: ellipse.h:63
auto set_model_view_matrix(Mat4< GLfloat > const &MV) -> void
Definition: shaders.h:89
auto set_color(GLfloat r, GLfloat g, GLfloat b, GLfloat a=1) -> void
Definition: shaders.h:85