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

◆ create_element() [2/2]

template<typename T >
Mapped< T > MayaFlux::Portal::Forma::create_element ( Surface surface,
GeometryFn< T >  geom,
initial,
Graphics::PrimitiveTopology  topology = Graphics::PrimitiveTopology::TRIANGLE_STRIP,
std::function< float(T)>  project = {} 
)

Build a FormaBuffer, register it, construct a Mapped<T>, add the element to surface's layer, and register it with the application Bridge.

Surface-accepting overload of create_element. Reads the layer and window from surface; everything else matches the existing (Layer&, Window) overload.

After registration, one sync() is run so that bounds_hint and contains populated by the geometry function are visible on the Element before the first frame. This removes the manual

layer->set_bounds(el.element.id, ...);
layer->set_contains(el.element.id, ...);

boilerplate seen at fader-style call sites: those values now arrive directly from the geometry function on construction. The geometry function remains the user's; the sync is the same one that runs every frame.

Template Parameters
TMappedState value type.
Parameters
surfaceCanvas to register the element on.
geomGeometry function producing vertex bytes from T.
initialStarting value written into MappedState.
topologyPrimitive topology for the FormaBuffer.
projectOptional T -> float projection for outbound readers.
Returns
Fully constructed Mapped<T> with element registered.

Definition at line 330 of file Forma.hpp.

335 {})
336{
337 return internal::atelier().create_element<T>(
338 surface, std::move(geom), std::move(initial), topology, std::move(project));
339}