template<class InstanceData>
Magnum::Ui::BasicInstancedLayer class

Base for instanced layers.

All elements in this layer have the same size and structure described by InstanceData. See BasicLayer for an alternative.

To use this type in a BasicPlane, you have to provide a void draw(AbstractUiShader&) function in a subclass that draws the contents using given shader.

Derived classes

template<class InstanceData>
class BasicInstancedGLLayer
Base for instanced layers with OpenGL backend.

Public functions

auto capacity() const -> std::size_t
Reserved instance capacity.
auto size() const -> std::size_t
Occupied instance count.
auto data() const -> Containers::ArrayView<const InstanceData>
Data.
auto modified() const -> Math::Range1D<std::size_t>
Modified range.
void resetModified()
Reset the modified range.
void reset(std::size_t capacity)
Reset the layer.
auto addElement(const InstanceData& instanceData) -> std::size_t
Add element.
auto modifyElement(std::size_t id) -> InstanceData&
Modify element.
auto elementData(std::size_t id) const -> const InstanceData&
Element data.

Function documentation

template<class InstanceData>
std::size_t Magnum::Ui::BasicInstancedLayer<InstanceData>::capacity() const

Reserved instance capacity.

template<class InstanceData>
std::size_t Magnum::Ui::BasicInstancedLayer<InstanceData>::size() const

Occupied instance count.

template<class InstanceData>
Containers::ArrayView<const InstanceData> Magnum::Ui::BasicInstancedLayer<InstanceData>::data() const

Data.

A view onto currently populated data (of size size(), not capacity()).

template<class InstanceData>
Math::Range1D<std::size_t> Magnum::Ui::BasicInstancedLayer<InstanceData>::modified() const

Modified range.

Range that needs to be updated on the GPU before drawing next frame.

template<class InstanceData>
void Magnum::Ui::BasicInstancedLayer<InstanceData>::resetModified()

Reset the modified range.

Call after uploading the modified data onto the GPU to clear the modifier range for next frame.

template<class InstanceData>
void Magnum::Ui::BasicInstancedLayer<InstanceData>::reset(std::size_t capacity)

Reset the layer.

Allocates memory to store given capacity of instances, clearing everything that has been set before. If current memory capacity is larger or equal to capacity, no reallocation is done.

template<class InstanceData>
std::size_t Magnum::Ui::BasicInstancedLayer<InstanceData>::addElement(const InstanceData& instanceData)

Add element.

Expects that the capacity is large enough to store the instance data. Returns ID of the element that can be used later to modify its contents using modifyElement().

template<class InstanceData>
InstanceData& Magnum::Ui::BasicInstancedLayer<InstanceData>::modifyElement(std::size_t id)

Modify element.

Parameters
id Element ID

Returns data for user to modify and marks them as modified. Expects that the ID is returned from previous addElement() call.

template<class InstanceData>
const InstanceData& Magnum::Ui::BasicInstancedLayer<InstanceData>::elementData(std::size_t id) const

Element data.

Returns constant view on the data. Expects that the ID is returned from previous addElement() call.