MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ background()

MAYAFLUX_API GeometryFn< float > MayaFlux::Portal::Forma::Plot::background ( Kinesis::AABB2D  bounds,
glm::vec3  color = glm::vec3(1.F),
const std::shared_ptr< Core::VKImage > &  texture = nullptr 
)

TRIANGLE_STRIP background quad for a plot area.

Produces a solid-color or textured full-screen quad covering bounds. Intended to be added to the same Layer as a plot element via Layer::relate, rendered before it.

When texture is non-null the quad uses the textured vertex path and the caller must pass a matching FormaBuffer with a texture binding. When null the quad is filled with color.

T is float (a dummy tick value — the background is static unless the caller drives it). Write any float to state->write() to refresh.

Parameters
boundsPlot area in NDC.
colorFill color when no texture is provided.
textureOptional GPU image. nullptr = solid color.

Definition at line 88 of file PlotSpec.cpp.

92{
93 return [bounds, color, texture](
94 float,
95 std::vector<uint8_t>& out,
96 Element& el) {
97 out.clear();
98
99 if (texture) {
100 const uint32_t stride = Kakshya::VertexLayout::for_textured_quad().stride_bytes;
101 const std::array<std::pair<glm::vec3, glm::vec2>, 4> verts = { {
102 { { bounds.min.x, bounds.min.y, 0.F }, { 0.F, 1.F } },
103 { { bounds.max.x, bounds.min.y, 0.F }, { 1.F, 1.F } },
104 { { bounds.min.x, bounds.max.y, 0.F }, { 0.F, 0.F } },
105 { { bounds.max.x, bounds.max.y, 0.F }, { 1.F, 0.F } },
106 } };
107 out.resize(static_cast<size_t>(4) * stride);
108 for (size_t i = 0; i < 4; ++i) {
109 uint8_t* v = out.data() + i * stride;
110 std::memcpy(v, &verts[i].first, 12);
111 std::memcpy(v + 12, &verts[i].second, 8);
112 }
113 } else {
114 const uint32_t stride = Kakshya::VertexLayout::for_meshes().stride_bytes;
115 constexpr glm::vec3 k_normal { 0.F, 0.F, 1.F };
116 constexpr glm::vec3 k_tangent { 1.F, 0.F, 0.F };
117 constexpr glm::vec2 k_uv { 0.F, 0.F };
118 constexpr float k_weight = 0.F;
119
120 const std::array<glm::vec3, 4> positions = { {
121 { bounds.min.x, bounds.min.y, 0.F },
122 { bounds.max.x, bounds.min.y, 0.F },
123 { bounds.min.x, bounds.max.y, 0.F },
124 { bounds.max.x, bounds.max.y, 0.F },
125 } };
126
127 out.resize(static_cast<size_t>(4) * stride, 0);
128 for (size_t i = 0; i < 4; ++i) {
129 uint8_t* v = out.data() + i * stride;
130 std::memcpy(v, &positions[i], 12);
131 std::memcpy(v + 12, &color, 12);
132 std::memcpy(v + 24, &k_weight, 4);
133 std::memcpy(v + 28, &k_uv, 8);
134 std::memcpy(v + 36, &k_normal, 12);
135 std::memcpy(v + 48, &k_tangent, 12);
136 }
137 }
138
139 el.bounds_hint = bounds;
140 };
141}
A bounded, renderable region on a window surface.
Definition Element.hpp:58

References MayaFlux::Kakshya::VertexLayout::for_meshes(), MayaFlux::Kakshya::VertexLayout::for_textured_quad(), MayaFlux::Kinesis::AABB2D::max, MayaFlux::Kinesis::AABB2D::min, and MayaFlux::Kakshya::VertexLayout::stride_bytes.

Referenced by MayaFlux::Portal::Forma::Plot::WaveformBuilder::done(), MayaFlux::Portal::Forma::Plot::ScatterBuilder::done(), MayaFlux::Portal::Forma::Plot::BarsBuilder::done(), and MayaFlux::Portal::Forma::Plot::FilledWaveformBuilder::done().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: