MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Element.cpp
Go to the documentation of this file.
1#include "Element.hpp"
2
4
8
10
11namespace {
12
13 /// @brief weight=1 is this pipeline's own convention, not Kinesis's: it
14 /// is what forma_multi.frag reads to select textures[0]. Kinesis::
15 /// textured_mesh_rect() has no opinion on what the value means -
16 /// that domain knowledge stays here, at the one place it applies.
17 constexpr float k_single_texture_weight = 1.F;
18
19} // namespace
20
22 const std::shared_ptr<Core::VKImage>& image,
23 Kinesis::AABB2D region)
24{
25 if (!buffer)
26 return *this;
27
28 texture = image;
29 buffer.submit(Kinesis::textured_mesh_rect(region, k_single_texture_weight));
31 return *this;
32}
33
35 const std::shared_ptr<Buffers::TextureBuffer>& buf,
36 Kinesis::AABB2D region)
37{
38 return with_texture(buf->get_texture(), region);
39}
40
42 std::string_view text,
43 std::optional<Portal::Text::PressParams> params,
44 Kinesis::AABB2D region)
45{
46 if (!buffer)
47 return *this;
48
50 buffer, region, params.value_or(Portal::Text::PressParams {}), text);
51 return *this;
52}
53
54void Element::set_text(std::string_view text, std::optional<Portal::Text::PressParams> params)
55{
56 if (!text_slice)
57 return;
58
59 text_slice->assign(text, params.value_or(Portal::Text::PressParams {}));
60}
61
63{
64 if (!buffer)
65 return *this;
66
67 if (text_slice) {
68 text_slice->set_bounds(region);
69 return *this;
70 }
71
72 buffer.submit(Kinesis::textured_mesh_rect(region, k_single_texture_weight));
73 return *this;
74}
75
76} // namespace MayaFlux::Portal::Forma
IO::ImageData image
Definition Decoder.cpp:47
void submit(const std::vector< uint8_t > &bytes) const
Replace this target's geometry.
Definition Target.cpp:51
void bind_texture(uint32_t array_index, const std::shared_ptr< Core::VKImage > &image) const
Bind a texture in the buffer's texture array.
Definition Target.cpp:63
static std::shared_ptr< TextSlice > make(FormaTarget target, Kinesis::AABB2D bounds, Text::PressParams params, std::string_view text)
Draw text in bounds on target.
Definition TextSlice.cpp:49
std::array< Kakshya::MeshVertex, 6 > textured_mesh_rect(Kinesis::AABB2D region, float weight, glm::vec3 color)
Generate a UV-mapped TRIANGLE_LIST quad (6 vertices, 2 triangles) from an AABB2D, as Kakshya::MeshVer...
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:63
Element & with_text(std::string_view text, std::optional< Portal::Text::PressParams > params, Kinesis::AABB2D region={ .min=glm::vec2(-1.F),.max=glm::vec2(1.F) })
Draw text as glyph quads into the attached buffer.
Definition Element.cpp:41
FormaTarget buffer
Where this region's rendered output is written: a buffer of its own, or a slice of one it shares.
Definition Element.hpp:82
std::shared_ptr< internal::TextSlice > text_slice
Text drawn into the attached buffer by with_text().
Definition Element.hpp:89
std::shared_ptr< Core::VKImage > texture
Optional GPU texture to bind to the attached buffer. Used for.
Definition Element.hpp:85
Element & with_texture(const std::shared_ptr< Core::VKImage > &image, Kinesis::AABB2D region={ .min=glm::vec2(-1.F),.max=glm::vec2(1.F) })
Submit a UV quad covering region and bind image as "texSampler" on the attached FormaBuffer.
Definition Element.cpp:21
Element & retarget(Kinesis::AABB2D region)
Move the element's output to a new NDC region.
Definition Element.cpp:62
void set_text(std::string_view text, std::optional< Portal::Text::PressParams > params)
Replace the text drawn by with_text().
Definition Element.cpp:54
A bounded, renderable region on a window surface.
Definition Element.hpp:61
Construction parameters for press().
Definition InkPress.hpp:65