template<class VertexData>
Magnum::Ui::BasicLayer class

Basic layer.

Contents

Elements in this layer can have variable size at a cost of duplicating per-element data for each vertex. Updating an element later with shorter size also means that the remaining vertices will still be drawn but need to be hidden somehow.

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 VertexData>
class BasicGLLayer
Layer with OpenGL backend.

Public functions

auto capacity() const -> std::size_t
Reserved vertex capacity.
auto elementCapacity() const -> std::size_t
Reserved element capacity.
auto size() const -> std::size_t
Occupied vertex count.
auto elementCount() const -> std::size_t
Occupied element count.
auto indexCount() const -> std::size_t
Index count to draw.
auto data() const -> Containers::ArrayView<const VertexData>
Data.
auto modified() const -> Math::Range1D<std::size_t>
Modified range.
void resetModified()
Reset the modified range.
void reset(std::size_t elementCapacity, std::size_t dataCapacity)
Reset the layer.
auto addElement(Containers::ArrayView<const VertexData> data, std::size_t indexCount) -> std::size_t
Add element.
auto modifyElement(std::size_t id) -> Containers::ArrayView<VertexData>
Modify element.
auto elementSize(std::size_t id) const -> std::size_t
Element size.
auto elementData(std::size_t id) const -> Containers::ArrayView<const VertexData>
Element data.

Function documentation

template<class VertexData>
std::size_t Magnum::Ui::BasicLayer<VertexData>::capacity() const

Reserved vertex capacity.

template<class VertexData>
std::size_t Magnum::Ui::BasicLayer<VertexData>::elementCapacity() const

Reserved element capacity.

template<class VertexData>
std::size_t Magnum::Ui::BasicLayer<VertexData>::size() const

Occupied vertex count.

template<class VertexData>
std::size_t Magnum::Ui::BasicLayer<VertexData>::elementCount() const

Occupied element count.

template<class VertexData>
std::size_t Magnum::Ui::BasicLayer<VertexData>::indexCount() const

Index count to draw.

Sum of all count parameters passed to addElement(). To be used as index count when drawing the mesh. If your layer doesn't use indexed draw, you can ignore this field.

template<class VertexData>
Containers::ArrayView<const VertexData> Magnum::Ui::BasicLayer<VertexData>::data() const

Data.

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

template<class VertexData>
Math::Range1D<std::size_t> Magnum::Ui::BasicLayer<VertexData>::modified() const

Modified range.

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

template<class VertexData>
void Magnum::Ui::BasicLayer<VertexData>::resetModified()

Reset the modified range.

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

template<class VertexData>
void Magnum::Ui::BasicLayer<VertexData>::reset(std::size_t elementCapacity, std::size_t dataCapacity)

Reset the layer.

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

template<class VertexData>
std::size_t Magnum::Ui::BasicLayer<VertexData>::addElement(Containers::ArrayView<const VertexData> data, std::size_t indexCount)

Add element.

Parameters
data Widget vertex data
indexCount Actual index count for the vertex data. If your layer doesn't use indexed draw, you can set any value here.

Expects that the capacity is large enough to store the vertex data. Returns ID of the element that can be used later to modify its contents.

template<class VertexData>
Containers::ArrayView<VertexData> Magnum::Ui::BasicLayer<VertexData>::modifyElement(std::size_t id)

Modify element.

Parameters
id Element ID

Marks returned data range as modified. Expects that the ID is returned from previous addElement() call.

template<class VertexData>
std::size_t Magnum::Ui::BasicLayer<VertexData>::elementSize(std::size_t id) const

Element size.

Parameters
id Element ID

Expects that the ID is returned from previous addElement() call.

template<class VertexData>
Containers::ArrayView<const VertexData> Magnum::Ui::BasicLayer<VertexData>::elementData(std::size_t id) const

Element data.

Parameters
id Element ID

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