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

◆ create_element() [1/2]

template<typename T >
Mapped< T > MayaFlux::Portal::Forma::create_element ( Layer layer,
std::shared_ptr< Core::Window window,
GeometryFn< T >  geom,
initial,
Graphics::PrimitiveTopology  topology = Graphics::PrimitiveTopology::TRIANGLE_STRIP,
size_t  capacity = internal::k_capacity_bytes,
std::function< float(T)>  project = {} 
)

Build a FormaBuffer, register it, construct a Mapped<T>, and add the element to layer.

BufferManager is taken from the stored initialize() state. Returns the fully constructed Mapped<T>. The caller holds it. element.id is stable and can be passed to Context callbacks and Bridge.

Template Parameters
TMappedState value type: float, glm::vec2, etc.
Parameters
layerLayer to register the element on.
windowTarget window for rendering.
geomGeometry function producing vertex bytes from T.
initialStarting value written into MappedState.
topologyPrimitive topology for the FormaBuffer.
capacityInitial FormaBuffer capacity in bytes.
projectOptional T -> float projection for outbound readers.
Returns
Fully constructed Mapped<T> with element registered in layer.

Definition at line 287 of file Forma.hpp.

294 {})
295{
296 auto buf = create_buffer(std::move(window), capacity, topology);
297 auto mapped = make_mapped<T>(initial, std::move(geom), buf);
298 mapped.element.id = layer.add(mapped.element);
299 bridge().register_element(mapped, std::move(project));
300 return mapped;
301}
void register_element(std::shared_ptr< MappedState< T > > state, uint32_t id, std::shared_ptr< Buffers::FormaBuffer > buffer, std::function< float(T)> project={})
Register a MappedState<T> so that MappedState overloads and outbound bindings can resolve to the corr...
Definition Bridge.hpp:280
Slot add(Element element)
Add an element to the layer.
Definition Layer.cpp:9
auto create_buffer(uint32_t channel, uint32_t buffer_size, Args &&... args) -> std::shared_ptr< BufferType >
creates a new buffer of the specified type and registers it
Definition Graph.hpp:339