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

◆ create()

template<typename T >
Mapped< T > MayaFlux::Portal::Forma::create ( Surface surface,
Geometry::Form< T >  form,
initial,
std::function< float(T)>  project = {} 
)

Realize a Form on surface.

Builds the buffer at the Form's capacity and topology, registers the element, syncs so the geometry function's bounds_hint and contains reach the Layer before the first frame, then runs the Form's interaction wiring.

A bare GeometryFn converts to a Form, so this also serves as the simplest element construction path for a caller's own geometry.

Template Parameters
TMappedState value type.
Parameters
surfaceCanvas to register on.
formGeometry, topology, capacity, and interaction.
initialStarting value written into MappedState.
projectOptional T to float projection for outbound readers.
Returns
Fully constructed Mapped<T>, wired.

Definition at line 277 of file Forma.hpp.

281 {})
282{
283 auto mapped = internal::atelier().create_element<T>(
284 surface.layer(), surface.window(),
285 std::move(form.geometry), std::move(initial),
286 form.topology, form.capacity, std::move(project));
287
288 mapped.sync();
289 if (mapped.element.bounds_hint)
290 surface.layer().set_bounds(mapped.element.id, *mapped.element.bounds_hint);
291 if (mapped.element.contains)
292 surface.layer().set_contains(mapped.element.id, mapped.element.contains);
293
294 if (form.wire)
295 form.wire(surface.ctx(), mapped.element.id, mapped.state);
296
297 return mapped;
298}
bool set_bounds(uint32_t id, Kinesis::AABB2D bounds)
Replace the bounds_hint on an existing element.
Definition Layer.cpp:36
bool set_contains(uint32_t id, std::function< bool(glm::vec2)> fn)
Replace the contains callable on an existing element.
Definition Layer.cpp:45
const std::shared_ptr< Core::Window > & window() const noexcept
Access the rendering target window.
Definition Surface.hpp:126
Context & ctx() noexcept
Access the event router.
Definition Surface.hpp:118
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:107
GeometryFn< T > geometry
Writes vertex bytes for the current value.
Definition Geometry.hpp:85
size_t capacity
FormaBuffer capacity in bytes for the vertex count geometry writes.
Definition Geometry.hpp:91
std::function< void(Context &, uint32_t, std::shared_ptr< MappedState< T > >)> wire
Registers interaction against the realized element.
Definition Geometry.hpp:100
Graphics::PrimitiveTopology topology
Topology matching the vertex kind geometry writes.
Definition Geometry.hpp:88