logo
pub unsafe trait Tess<V, I, W, S> where
    V: TessVertexData<S>,
    I: TessIndex,
    W: TessVertexData<S>,
    S: ?Sized
{ type TessRepr; unsafe fn build(
        &mut self,
        vertex_data: Option<V::Data>,
        index_data: Vec<I>,
        instance_data: Option<W::Data>,
        mode: Mode,
        restart_index: Option<I>
    ) -> Result<Self::TessRepr, TessError>; unsafe fn tess_vertices_nb(tess: &Self::TessRepr) -> usize; unsafe fn tess_indices_nb(tess: &Self::TessRepr) -> usize; unsafe fn tess_instances_nb(tess: &Self::TessRepr) -> usize; unsafe fn render(
        tess: &Self::TessRepr,
        start_index: usize,
        vert_nb: usize,
        inst_nb: usize
    ) -> Result<(), TessError>; }
Expand description

Tessellation support on the backend.

This trait is a bit complex at first glance because of the number of type variables.

  • V is the type of vertex, and requires the TessVertexData trait to be implemented with S. More on this below.
  • I is the type of index, and requires the TessIndex trait to be implemented.
  • W is the type of instance and also requires TessVertexData:
  • S is the storage type and acts as a marker for backends.

S is an important type variable here, because it gives the Tess its memory storage layout. You can use any type you want here but as a backend, you will want to implement Tess for S with the Interleaved and Deinterleaved types. Those two types are the ones used in the API, so the backends are expected to implement them.

You will want to have a look at TessVertexData and TessIndex to know how to make your vertex and index types compatible with Tess.

Required Associated Types

Backend representation of the tessellation.

Required Methods

Build a tessellation from vertex, index, instance and mode data.

This method is used after a builder has enough information to build a Tess. The data is highly polymorphic so you will have to provide the types for the data containers when implementing both TessVertexData and TessIndex. By convention, the idea is that:

  • If S is Interleaved, you will want to take a single Vec for vertices and either a Vec or [()] for indices and instance data.
  • If S is Deinterleaved, you will want to take a Vec of DeinterleavedData for vertices and instance data (it doesn’t make any difference for indices, so stick to Vec and [()]). DeinterleavedData contains its own Vec, so you basically end up with a Vec of Vec, allowing to provide separate attributes for all the vertices in their own containers.

Number of vertices available in the Tess.

Number of indices available in the Tess.

Number of instance data available in the Tess.

Render the tessellation, starting at start_index, rendering vert_nb vertices, instantiating inst_nb times.

If inst_nb is 0, you should perform a render as if you were asking for 1.

Implementors