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 theTessVertexData
trait to be implemented withS
. More on this below.I
is the type of index, and requires theTessIndex
trait to be implemented.W
is the type of instance and also requiresTessVertexData
: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
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
isInterleaved
, you will want to take a singleVec
for vertices and either aVec
or [()
] for indices and instance data. - If
S
isDeinterleaved
, you will want to take aVec
ofDeinterleavedData
for vertices and instance data (it doesn’t make any difference for indices, so stick toVec
and [()
]).DeinterleavedData
contains its ownVec
, so you basically end up with aVec
ofVec
, allowing to provide separate attributes for all the vertices in their own containers.
unsafe fn tess_vertices_nb(tess: &Self::TessRepr) -> usize
unsafe fn tess_vertices_nb(tess: &Self::TessRepr) -> usize
Number of vertices available in the Tess
.
unsafe fn tess_indices_nb(tess: &Self::TessRepr) -> usize
unsafe fn tess_indices_nb(tess: &Self::TessRepr) -> usize
Number of indices available in the Tess
.
unsafe fn tess_instances_nb(tess: &Self::TessRepr) -> usize
unsafe fn tess_instances_nb(tess: &Self::TessRepr) -> usize
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
.