Build tessellations the easy way.
This type allows you to create
Tess by specifying piece-by-piece what the tessellation is
made of. Several situations and configurations are supported.
If you want to create a
Tess holding vertices without anything else, you want to use the
TessBuilder::add_vertices. Every time that function is called, a vertex buffer is
virtually allocated for your tessellation, which gives you three possibilities:
If you don’t call that function, you end up with an attributeless tessellation. Such a tessellation has zero memory allocated to vertices. Instead, when invoking a vertex shader, the vertices must be created on the fly inside the vertex shader directly.
If you call that function once, you have a single vertex buffer allocated, which either
gives you a 1-attribute tessellation, or an interleaved tessellation. Interleaved tessellation
allows you to use a Rust
struct (if it implements the
Vertex trait) as vertex type and
easily fetch them from a vertex shader.
If you call that function several times, the
TessBuilder assumes you want deinterleaved
memory, which means that each patch of vertices you add is supposed to contain one type of
deinterleaved vertex attributes. A coherency check is done by the
TessBuilder to ensure
the vertex data is correct.
By default, vertices are picked in the order you specify them in the vertex buffer(s). If you want more control on the order, you can add indices.
As soon as you provide indices, the
TessBuilder will change the way
Tess will fetch
vertices. Instead of fetching the first vertex, then second, then third, etc., it will first
fetch the first index, then the second, then third, and respectively use the value of those
indices to fetch the actual vertices.
For instance, if instead of fetching vertices
[1, 2, 3] (which is the default) you want to
[12, 35, 2], you can add the
[12, 35, 2] indices in the
Tess will fetch the first index and get
12; it will then make the first
vertex to be fetched the 12th; then fetch the second index; get
35 and fetch the 35th vertex.
Finally, as you might have guessed, it will fetch the third index, get
2 and then the third
vertex to be fetched will be the second one.
That feature is really important as it allows you to factorize vertices: instead of duplicating them, you can just reuse their indices.
You can have only one set of indices. See the
It’s also possible to provide instancing information. Those are special vertex attributes that are picked on an instance-based information instead of vertex number one. It works very similarly to how vertices data work, but on a per-instance bases.
TessBuilder::add_instances function for further details.
impl<'a, C> TessBuilder<'a, C>[src]
impl<'a, C> TessBuilder<'a, C> where[src]
Add vertices to be part of the tessellation.
This method can be used in several ways. First, you can decide to use interleaved memory, in which case you will call this method only once by providing an interleaved slice / borrowed buffer. Second, you can opt-in to use deinterleaved memory, in which case you will have several, smaller buffers of borrowed data and you will issue a call to this method for all of them.
Add instances to be part of the tessellation.
Set vertex indices in order to specify how vertices should be picked by the GPU pipeline.
Set the primitive mode for the building
pub fn set_vertex_nb(self, nb: usize) -> Self[src]
Set the default number of vertices to be rendered.
That function is not mandatory if you are not building an attributeless tessellation but is if you are.
When called while building a
Tess owning at least one vertex buffer, it acts as a default
number of vertices to render and is useful when you will slice the tessellation with open
pub fn set_instance_nb(self, nb: usize) -> Self[src]
Set the default number of instances to render.
0 disables geometry instancing.
pub fn set_primitive_restart_index(self, index: Option<u32>) -> Self[src]
Set the primitive restart index. The initial value is
None, implying no primitive restart.
impl<'a, C> !RefUnwindSafe for TessBuilder<'a, C>
impl<'a, C> !Send for TessBuilder<'a, C>
impl<'a, C> !Sync for TessBuilder<'a, C>
impl<'a, C> Unpin for TessBuilder<'a, C>
impl<'a, C> !UnwindSafe for TessBuilder<'a, C>
type Error = Infallible
The type returned in the event of a conversion error.