class
MeshViewMesh view.
Contents
Allows different interpretation of given Mesh data via different vertex or index count and offset. It is then possible to reuse one mesh buffer configuration for different views. Mesh primitive, index type, attribute bindings and attached buffers are reused from original mesh.
The same rules as in Mesh apply, i.e. if the view has non-zero index count, it is treated as indexed mesh, otherwise it is treated as non-indexed mesh. If both index and vertex count is zero, the view is treated as empty and no draw commands are issued when calling draw().
You must ensure that the original mesh remains available for whole view lifetime.
Public static functions
-
static void draw(AbstractShaderProgram& shader,
std::
initializer_list<std:: reference_wrapper<MeshView>> meshes) - Draw multiple meshes at once.
-
static void draw(AbstractShaderProgram&& shader,
std::
initializer_list<std:: reference_wrapper<MeshView>> meshes)
Constructors, destructors, conversion operators
Public functions
- auto operator=(const MeshView&) -> MeshView& defaulted
- Copy assignment.
- auto operator=(MeshView&& other) -> MeshView& deleted
- Movement is not allowed.
- auto mesh() -> Mesh&
- Original mesh.
- auto mesh() const -> const Mesh&
- auto count() const -> Int
- Vertex/index count.
- auto setCount(Int count) -> MeshView&
- Set vertex/index count.
- auto baseVertex() const -> Int
- Base vertex.
- auto setBaseVertex(Int baseVertex) -> MeshView&
- Set base vertex.
- auto setIndexRange(Int first, UnsignedInt start, UnsignedInt end) -> MeshView&
- Set index range.
- auto setIndexRange(Int first) -> MeshView&
- Set index range.
- auto instanceCount() const -> Int
- Instance count.
- auto setInstanceCount(Int count) -> MeshView&
- Set instance count.
- auto baseInstance() const -> UnsignedInt
- Base instance.
- auto setBaseInstance(UnsignedInt baseInstance) -> MeshView&
- Set base instance.
- void draw(AbstractShaderProgram& shader)
- Draw the mesh.
- void draw(AbstractShaderProgram&& shader)
- void draw(AbstractShaderProgram& shader, TransformFeedback& xfb, UnsignedInt stream = 0)
- Draw the mesh with vertices coming out of transform feedback.
- void draw(AbstractShaderProgram&& shader, TransformFeedback& xfb, UnsignedInt stream = 0)
Function documentation
static void Magnum:: GL:: MeshView:: draw(AbstractShaderProgram& shader,
std:: initializer_list<std:: reference_wrapper<MeshView>> meshes)
Draw multiple meshes at once.
In OpenGL ES, if EXT_
If ARB_
static void Magnum:: GL:: MeshView:: draw(AbstractShaderProgram&& shader,
std:: initializer_list<std:: reference_wrapper<MeshView>> meshes)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MeshView& Magnum:: GL:: MeshView:: setCount(Int count)
Set vertex/index count.
Returns | Reference to self (for method chaining) |
---|
Ignored when calling draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt). Default is 0
.
MeshView& Magnum:: GL:: MeshView:: setBaseVertex(Int baseVertex)
Set base vertex.
Returns | Reference to self (for method chaining) |
---|
Sets number of vertices of which the vertex buffer will be offset when drawing. Ignored when calling draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt). Default is 0
.
MeshView& Magnum:: GL:: MeshView:: setIndexRange(Int first,
UnsignedInt start,
UnsignedInt end)
Set index range.
Parameters | |
---|---|
first | First vertex |
start | Minimum array index contained in the buffer |
end | Maximum array index contained in the buffer |
Returns | Reference to self (for method chaining) |
The start
and end
parameters may help to improve memory access performance, as only a portion of vertex buffer needs to be acccessed. On OpenGL ES 2.0 this function behaves the same as setIndexRange(Int), as index range functionality is not available there. Ignored when calling draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt).
Expects that the original mesh is indexed.
MeshView& Magnum:: GL:: MeshView:: setIndexRange(Int first)
Set index range.
Parameters | |
---|---|
first | First index |
Returns | Reference to self (for method chaining) |
Prefer to use setIndexRange(Int, UnsignedInt, UnsignedInt) for better performance. Ignored when calling draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt).
Expects that the original mesh is indexed.
MeshView& Magnum:: GL:: MeshView:: setInstanceCount(Int count)
Set instance count.
Returns | Reference to self (for method chaining) |
---|
Default is 1
.
MeshView& Magnum:: GL:: MeshView:: setBaseInstance(UnsignedInt baseInstance)
Set base instance.
Returns | Reference to self (for method chaining) |
---|
Ignored when calling draw(AbstractShaderProgram&, TransformFeedback&, UnsignedInt). Default is 0
.
void Magnum:: GL:: MeshView:: draw(AbstractShaderProgram& shader)
Draw the mesh.
See Mesh::
void Magnum:: GL:: MeshView:: draw(AbstractShaderProgram&& shader)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: MeshView:: draw(AbstractShaderProgram& shader,
TransformFeedback& xfb,
UnsignedInt stream = 0)
Draw the mesh with vertices coming out of transform feedback.
Everything set by setCount(), setBaseInstance(), setBaseVertex(), setIndexRange() and Mesh::xfb
object. See Mesh::
void Magnum:: GL:: MeshView:: draw(AbstractShaderProgram&& shader,
TransformFeedback& xfb,
UnsignedInt stream = 0)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.